diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/README.md b/README.md index 714bedc..3605b26 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Docker templates for different programming languages -### Angular +## Angular Move Dockerfile, docker-compose.yml and .dockerignore into top level Angular app directory (my_angular_app/ and not my_angular_app/src) @@ -29,7 +29,18 @@ docker run --name app -p 4200:4200 -v nodemodules:/src/node_modules -v .:/src MY_IMAGE_NAME ``` -or to start via Docker compose +## Python + +For the local version of docker compose, the environment variables +shown are required if the app needs to use GCP client libraries. + +For production, there may be additional permissions that are required to run +the application on GCP. + + +## Docker / Docker Compose Notes + +### Start via Docker compose ```bash docker compose up @@ -39,4 +50,14 @@ ```bash docker compose down +``` + +### Build + +```bash +docker build -t -f . +``` + +```bash +docker compose -f {up | down} ``` \ No newline at end of file diff --git a/python/Dockerfile.local b/python/Dockerfile.local new file mode 100644 index 0000000..9acbe3c --- /dev/null +++ b/python/Dockerfile.local @@ -0,0 +1,16 @@ +FROM python:alpine3.12 + +WORKDIR /src + +COPY ./src/requirements.txt /src +RUN pip install -r requirements.txt + +# RUN gcloud auth application-default login + +COPY . /src + +EXPOSE 5000 + +ENV FLASK_APP=app + +CMD ["flask", "--app" "main.py" "--debug" "run"] \ No newline at end of file diff --git a/python/Dockerfile.prod b/python/Dockerfile.prod new file mode 100644 index 0000000..53ca220 --- /dev/null +++ b/python/Dockerfile.prod @@ -0,0 +1,16 @@ +FROM python:alpine3.12 + +WORKDIR /src + +COPY ./src/requirements.txt /src +RUN pip install -r requirements.txt + +# RUN gcloud auth application-default login + +COPY . /src + +EXPOSE 5000 + +ENV FLASK_APP=app + +CMD ["gunicorn", "-b", "0.0.0.0:5000", "main:app"] \ No newline at end of file diff --git a/python/docker-compose.local.yml b/python/docker-compose.local.yml new file mode 100644 index 0000000..8089d91 --- /dev/null +++ b/python/docker-compose.local.yml @@ -0,0 +1,16 @@ +version: "3" + +services: + app: + build: . + ports: + - 5000:5000 + volumes: + - ./src:/src + - ${ADC}:/tmp/keys/application_default_credentials.json:ro + environment: + GOOGLE_APPLICATION_CREDENTIALS: /tmp/keys/application_default_credentials.json + GOOGLE_CLOUD_PROJECT: ${PROJECT} + +# Setting enviornment variables +# https://stackoverflow.com/questions/74866327/oserror-whilst-trying-to-run-a-python-app-inside-a-docker-container-using-appl diff --git a/python/docker-compose.prod.yml b/python/docker-compose.prod.yml new file mode 100644 index 0000000..339d06f --- /dev/null +++ b/python/docker-compose.prod.yml @@ -0,0 +1,12 @@ +version: "3" + +services: + app: + build: . + ports: + - 5000:5000 + volumes: + - ./src:/src + +# Setting enviornment variables +# https://stackoverflow.com/questions/74866327/oserror-whilst-trying-to-run-a-python-app-inside-a-docker-container-using-appl