Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Dockerfile #106

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions examples/first-docker-file/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
# Use an official Ubuntu as a base image
FROM ubuntu:latest

# Set the working directory in the image
# Set the working directory inside the container
WORKDIR /app

# Copy the files from the host file system to the image file system
COPY . /app
# Install necessary dependencies (Python, pip, venv)
RUN apt-get update && \
apt-get install -y python3 python3-pip python3-venv

# Create and activate a virtual environment
RUN python3 -m venv /venv

# Upgrade pip inside the virtual environment
RUN /venv/bin/pip install --upgrade pip

# Copy the requirements file into the container
COPY requirements.txt .

# Install the necessary packages
RUN apt-get update && apt-get install -y python3 python3-pip
# Install the Python dependencies into the virtual environment
RUN /venv/bin/pip install -r requirements.txt

# Set environment variables
# Copy the rest of the application files
COPY . /app

# Set environment variable (optional)
ENV NAME World

# Run a command to start the application
# Add virtual environment's binary folder to PATH
ENV PATH="/venv/bin:$PATH"

# Set the command to run your app (using the virtual environment's Python)
CMD ["python3", "app.py"]