I have recently set up an automated build repository by connecting my docker account with GitHub. I have made some small examples with a single Dockerfile in the project.
I have just a simple HTML file where I just print a paragraph, running it on NGINX. The Dockerfile looks as below:
FROM nginx:latest
LABEL maintainer="JohnDoe" \
name="DemoWebGit" \
version="1.0"
ENV CONTAINER_HOME=/usr/share/nginx/html
WORKDIR $CONTAINER_HOME
ADD /myweb $CONTAINER_HOME
This works as I expected. Every time I push some code, the latest docker image is also built. If I have a release with a specific version, it works with the specific tag as I have configured it.
Now, I am trying to build a Flask based app which runs with gunicorn and NGINX. The NGINX flask depends on my Flask application. Thus, I had to fix this through the docker-compose feature. The docker-compose file looks as below:
services:
nginx:
image: nginx:latest
container_name: nginx
volumes:
- ./default.conf:/etc/nginx/conf.d/default.conf
ports:
- 80:80
networks:
- mynetwork
depends_on:
- myflaskapp
myflaskapp:
build: ./dockerfiles/Dockerfile
container_name: myflaskapp
command: gunicorn --bind 0.0.0.0:8000 "myflaskapp:get_app()"
ports:
- 8000:80
volumes:
- ./:/var/www
networks:
mynetwork:
aliases:
- myflask-app
networks:
mynetwork:
When I run docker-compose up
this works just fine. However, I am trying to automate this one, but it seems that it always looks for the Dockerfile within the project. Now that I have two containers running simultaneously, I do now know how this can build a single image? Is there any way to automate this process and similar to this one, i.e. Php and MySQL?