Requirements and Setup
16%
The Container
Let's create a Docker image for our todo application. We start by creating a Dockerfile. Use the following command to create the file:
cat << EOF > $HOME/todo/app/Dockerfile
# Use an official Python runtime as a parent image
FROM python:3.12-slim
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Make port 5000 available to the world outside this container
EXPOSE 5000
# Define environment variable
CMD ["python", "app.py"]
EOF
Install Docker:
# Download the Docker installation script
curl -fsSL https://get.docker.com -o /tmp/get-docker.sh
# Run the installation script
sh /tmp/get-docker.sh
Build the image using the following command:
docker build -t todo-app $HOME/todo/app
Cloud Native CI/CD with GitLab
From Commit to Production ReadyEnroll now to unlock all content and receive all future updates for free.
