Task Overview
This tutorial demonstrates how you can easily start using werf with Dockerfile. We will build the application image and publish it to the local Docker registry. For example, we choose simple project — Linux Tweet App.
Requirements
- Minimal knowledge of Docker and Dockerfile instructions.
- Installed werf dependencies on the host system.
- Installed multiwerf on the host system.
Select werf version
This command should be run prior to running any other werf command in your shell session:
. $(multiwerf use 1.1 stable --as-file)
Step 1: Add a werf configuration
Add a special file called werf.yaml
to the source code and define application image based on project Dockerfile.
-
Clone the Linux Tweet App repository to get the source code:
git clone https://github.com/dockersamples/linux_tweet_app.git cd linux_tweet_app
-
In the project root directory create a
werf.yaml
with the following content:project: g-started configVersion: 1 --- image: ~ dockerfile: Dockerfile
Step 2: Build and Check the Application
-
Build an image (execute in the project root directory):
werf build --stages-storage :local
-
Run a container from the image:
werf run --stages-storage :local --docker-options="-d -p 80:80"
-
Check that the application runs and responds by opening
http://localhost:80
in your browser or executing:curl localhost:80
Step 3: Publish built image to Docker registry
-
Run local Docker registry:
docker run -d -p 5000:5000 --restart=always --name registry registry:2
-
Publish image using custom tagging strategy with docker tag
v0.1.0
:werf publish --stages-storage :local --images-repo localhost:5000/g-started --tag-custom v0.1.0
What’s next?
Firstly, you can plunge into the relevant documentation:
- werf configuration file.
- Dockerfile Image: complete directive list.
- Build procedure.
- Publish procedure.
Or go further: