-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #163 from AutomatingSciencePipeline/python-develop…
…ment-hot-reload Python development hot reload
- Loading branch information
Showing
7 changed files
with
70 additions
and
35 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,60 @@ | ||
# For more information, please refer to https://aka.ms/vscode-docker-python | ||
FROM python:3.8-slim | ||
FROM python:3.8-slim AS base | ||
|
||
ARG BACKEND_PORT | ||
ENV BACKEND_PORT=$BACKEND_PORT | ||
|
||
# Keeps Python from generating .pyc files in the container | ||
# This doesn't benefit the performance of the system | ||
# https://stackoverflow.com/questions/59732335/is-there-any-disadvantage-in-using-pythondontwritebytecode-in-docker | ||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
|
||
# Turns off buffering for easier container logging | ||
ENV PYTHONUNBUFFERED=1 | ||
|
||
RUN apt-get update | ||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends \ | ||
# For file type identification via bytes | ||
libmagic1 \ | ||
#Ths should also get Java 11? -David | ||
default-jdk | ||
|
||
#Ths should also get Java 11? -David | ||
RUN apt-get install default-jdk -y | ||
# Ability to pass in JVM options | ||
ARG JAVA_OPTS | ||
ENV JAVA_OPTS=$JAVA_OPTS | ||
|
||
# For file type identification via bytes | ||
RUN apt-get install libmagic1 -y | ||
|
||
# RUN apt-get update && \ | ||
# apt-get -y install sudo | ||
|
||
# Install requirements | ||
# Copy in python requirements definitions, but don't install yet, dev and prod need different deps | ||
RUN pip install pipenv | ||
COPY Pipfile . | ||
COPY Pipfile.lock . | ||
|
||
|
||
|
||
|
||
FROM base AS development | ||
# Args explanation: https://stackoverflow.com/a/49705601 | ||
# https://pipenv-fork.readthedocs.io/en/latest/basics.html#pipenv-install | ||
RUN pipenv install --system --deploy --ignore-pipfile | ||
# and also https://stackoverflow.com/a/53101932 | ||
RUN pipenv install --system --deploy --ignore-pipfile --dev | ||
|
||
WORKDIR /app | ||
COPY . /app | ||
|
||
# Creates a non-root user with an explicit UID and adds permission to access the /app folder | ||
# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers | ||
# RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app | ||
# RUN usermod -aG sudo appuser | ||
# USER appuser | ||
# RUN chmod -R a=rwx /app | ||
# The source code will be bind monuted in via docker compose, so we don't need to copy it in here | ||
|
||
USER root | ||
ENV FLASK_ENV development | ||
ENV FLASK_DEBUG 1 | ||
CMD flask run --host=0.0.0.0 --no-debugger -p $BACKEND_PORT | ||
|
||
# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug | ||
|
||
# TODO switch to ${BACKEND_PORT} | ||
CMD ["flask", "run", "--host=0.0.0.0", "-p", "5050"] | ||
|
||
|
||
FROM base AS production | ||
# Args explanation: https://stackoverflow.com/a/49705601 | ||
# https://pipenv-fork.readthedocs.io/en/latest/basics.html#pipenv-install | ||
RUN pipenv install --system --deploy --ignore-pipfile | ||
|
||
WORKDIR /app | ||
COPY . /app | ||
|
||
USER root | ||
ENV FLASK_ENV production | ||
CMD flask run --host=0.0.0.0 -p $BACKEND_PORT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Use this docker-compose file in addition to the base one in order to set up development configurations for the containers | ||
# https://docs.docker.com/compose/extends/ | ||
|
||
version: '3' | ||
name: glados-project | ||
|
||
services: | ||
app-backend: | ||
build: | ||
target: development | ||
volumes: | ||
- ./apps/backend/:/app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters