Skip to content

Instantly share code, notes, and snippets.

@mvoitko
Created July 23, 2019 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvoitko/84cb93a2bec5b835ab04999814de5f0f to your computer and use it in GitHub Desktop.
Save mvoitko/84cb93a2bec5b835ab04999814de5f0f to your computer and use it in GitHub Desktop.
The elegant method of activating virtualenv in Python container
FROM ubuntu:18.04
RUN apt-get update && apt-get install \
-y --no-install-recommends python3 python3-virtualenv
ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m virtualenv --python=/usr/bin/python3 $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
# Install dependencies:
COPY requirements.txt .
RUN pip install -r requirements.txt
# Run the application:
COPY myapp.py .
CMD ["python", "myapp.py"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment