INFO 253B: Backend Web Architecture
Kay Ashaolu
FROM python:3.9-alpine
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
EXPOSE 5000
ENTRYPOINT ["python3"]
CMD ["-m", "flask", "--app", "quote", "run", "--host=0.0.0.0", "--port=5000"]
# In terminal
# This command build the image and tags it with a name that you can refer to later
docker build -t quote_service_image .
# This command executes an container based on the image built above. It assigns an
# environment variable "FLASK_APP", and it maps http://localhost:5000 on your host
# machine to the flask app on port 5000 one he container.
#
# The EXPOSE keyword in the docker file tells docker
# that the container is communicating on port 5000, but your docker run command must
# map that port to a port on the host machine
docker run -dit --name=quote_service_container -p 5050:5000 quote_service_image
# To see and follow the logs of a running container (Ctrl-C to exit)
docker logs -f quote_service_container
# Now check http://localhost:5050 on host computer to see if it worked (note port 5000 in
# container is mapped to port 5050 on your computer)