From f63018c6dbe7fa2c46a7ec6010bf05227938cc36 Mon Sep 17 00:00:00 2001 From: deflax Date: Fri, 17 Nov 2023 19:58:12 -0500 Subject: [PATCH] remove dev setup --- docker-compose.yml | 4 +-- flask/Dockerfile | 58 +++++++++++++++++++++++++++++---- flask/Dockerfile.prod | 69 ---------------------------------------- flask/entrypoint.prod.sh | 14 -------- flask/entrypoint.sh | 2 -- tileserver/Dockerfile | 13 -------- 6 files changed, 54 insertions(+), 106 deletions(-) delete mode 100644 flask/Dockerfile.prod delete mode 100755 flask/entrypoint.prod.sh delete mode 100644 tileserver/Dockerfile diff --git a/docker-compose.yml b/docker-compose.yml index 618eb30..1bc8a0e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,8 +12,8 @@ services: - internal pgadmin: image: dpage/pgadmin4 - #volumes: - # - "./data/dbadmin:/var/lib/pgadmin" + volumes: + - "./data/dbadmin:/var/lib/pgadmin" env_file: - ./.env restart: always diff --git a/flask/Dockerfile b/flask/Dockerfile index 080ab9b..d13012c 100644 --- a/flask/Dockerfile +++ b/flask/Dockerfile @@ -1,5 +1,9 @@ +########### +# BUILDER # +########### + # pull official base image -FROM python:3.9.5-slim-buster +FROM python:3 as builder # set work directory WORKDIR /usr/src/app @@ -9,15 +13,57 @@ ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 # install system dependencies -RUN apt-get update && apt-get install -y netcat +RUN apt-get update && \ + apt-get install -y --no-install-recommends gcc + +# lint +RUN pip install --upgrade pip +RUN pip install flake8 +COPY . /usr/src/app/ +RUN flake8 --ignore=E501,F401 . + +# install python dependencies +COPY ./requirements.txt . +RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt + + +######### +# FINAL # +######### + +# pull official base image +FROM python:3 + +# create directory for the app user +RUN mkdir -p /home/app + +# create the app user +RUN addgroup --system app && adduser --system --group app + +# create the appropriate directories +ENV HOME=/home/app +ENV APP_HOME=/home/app/web +RUN mkdir $APP_HOME +WORKDIR $APP_HOME # install dependencies +RUN apt-get update && apt-get install -y --no-install-recommends netcat +COPY --from=builder /usr/src/app/wheels /wheels +COPY --from=builder /usr/src/app/requirements.txt . RUN pip install --upgrade pip -COPY ./requirements.txt /usr/src/app/requirements.txt -RUN pip install -r requirements.txt +RUN pip install --no-cache /wheels/* + +# copy entrypoint.sh +COPY ./entrypoint.sh $APP_HOME # copy project -COPY . /usr/src/app/ +COPY . $APP_HOME + +# chown all the files to the app user +RUN chown -R app:app $APP_HOME + +# change to the app user +USER app # run entrypoint.sh -ENTRYPOINT ["/usr/src/app/entrypoint.sh"] +ENTRYPOINT ["/home/app/web/entrypoint.sh"] diff --git a/flask/Dockerfile.prod b/flask/Dockerfile.prod deleted file mode 100644 index f7d8551..0000000 --- a/flask/Dockerfile.prod +++ /dev/null @@ -1,69 +0,0 @@ -########### -# BUILDER # -########### - -# pull official base image -FROM python:3.9.5-slim-buster as builder - -# set work directory -WORKDIR /usr/src/app - -# set environment variables -ENV PYTHONDONTWRITEBYTECODE 1 -ENV PYTHONUNBUFFERED 1 - -# install system dependencies -RUN apt-get update && \ - apt-get install -y --no-install-recommends gcc - -# lint -RUN pip install --upgrade pip -RUN pip install flake8==3.9.1 -COPY . /usr/src/app/ -#RUN flake8 --ignore=E501,F401 . - -# install python dependencies -COPY ./requirements.txt . -RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt - - -######### -# FINAL # -######### - -# pull official base image -FROM python:3.9.5-slim-buster - -# create directory for the app user -RUN mkdir -p /home/app - -# create the app user -RUN addgroup --system app && adduser --system --group app - -# create the appropriate directories -ENV HOME=/home/app -ENV APP_HOME=/home/app/web -RUN mkdir $APP_HOME -WORKDIR $APP_HOME - -# install dependencies -RUN apt-get update && apt-get install -y --no-install-recommends netcat -COPY --from=builder /usr/src/app/wheels /wheels -COPY --from=builder /usr/src/app/requirements.txt . -RUN pip install --upgrade pip -RUN pip install --no-cache /wheels/* - -# copy entrypoint-prod.sh -COPY ./entrypoint.prod.sh $APP_HOME - -# copy project -COPY . $APP_HOME - -# chown all the files to the app user -RUN chown -R app:app $APP_HOME - -# change to the app user -USER app - -# run entrypoint.prod.sh -ENTRYPOINT ["/home/app/web/entrypoint.prod.sh"] diff --git a/flask/entrypoint.prod.sh b/flask/entrypoint.prod.sh deleted file mode 100755 index 37fa201..0000000 --- a/flask/entrypoint.prod.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -if [ "$DATABASE" = "postgres" ] -then - echo "Waiting for postgres..." - - while ! nc -z $SQL_HOST $SQL_PORT; do - sleep 0.1 - done - - echo "PostgreSQL started" -fi - -exec "$@" diff --git a/flask/entrypoint.sh b/flask/entrypoint.sh index 3069d16..37fa201 100755 --- a/flask/entrypoint.sh +++ b/flask/entrypoint.sh @@ -11,6 +11,4 @@ then echo "PostgreSQL started" fi -python manage.py create_db - exec "$@" diff --git a/tileserver/Dockerfile b/tileserver/Dockerfile deleted file mode 100644 index 7d67b26..0000000 --- a/tileserver/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM overv/openstreetmap-tile-server:2.3.0 -EXPOSE 80 -# Remove all original style files -RUN rm -rf /home/renderer/src/openstreetmap-carto/style/*.mss -RUN rm -fr /home/renderer/src/openstreetmap-carto/project.mml -# Add custom style files -ADD carto-style /home/renderer/src/openstreetmap-carto -# Recompile the stylesheet -RUN cd /home/renderer/src/openstreetmap-carto \ - && carto project.mml > mapnik.xml \ - && scripts/get-external-data.py - -##TODO ADD map-data/