From 1ecbf6e933ccc4902e904a4691d73f399d4f3947 Mon Sep 17 00:00:00 2001 From: yxtay Date: Tue, 30 Jan 2024 14:46:15 +0800 Subject: [PATCH] build: improve dockerfile --- .gitignore | 6 +++--- Dockerfile | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 163782e..3faad34 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ # Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class +**/__pycache__/ +**/*.py[cod] +**/*$py.class # C extensions *.so diff --git a/Dockerfile b/Dockerfile index fa48683..7227a5a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,13 +10,13 @@ ARG UID=1000 RUN useradd --no-create-home --shell /bin/false --uid ${UID} ${USER} # set up environment -ARG VIRTUAL_ENV=/opt/venv +ARG VIRTUAL_ENV=/work/venv ENV PYTHONFAULTHANDLER=1 \ PYTHONUNBUFFERED=1 \ VIRTUAL_ENV=${VIRTUAL_ENV} \ PATH=${VIRTUAL_ENV}/bin:${PATH} -ARG APP_HOME=/opt/app +ARG APP_HOME=/work/app WORKDIR ${APP_HOME} ## @@ -24,19 +24,19 @@ WORKDIR ${APP_HOME} ## FROM base AS dev +ARG DEBIAN_FRONTEND=noninteractive RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ rm -f /etc/apt/apt.conf.d/docker-clean && \ apt-get update && \ apt-get install --no-install-recommends -y \ build-essential \ - curl \ + curl \ && rm -rf /var/lib/apt/lists/* ENV PYTHONDONTWRITEBYTECODE=1 \ PIP_DISABLE_PIP_VERSION_CHECK=1 \ PIP_NO_COMPILE=1 \ - POETRY_NO_INTERACTION=1 \ - POETRY_VIRTUALENVS_CREATE=0 + POETRY_NO_INTERACTION=1 # set up python RUN --mount=type=cache,target=/root/.cache/pip \ @@ -59,7 +59,7 @@ RUN --mount=type=cache,target=/root/.cache/pypoetry \ EXPOSE 8000 ARG ENVIRONMENT=dev ENV ENVIRONMENT ${ENVIRONMENT} -CMD ["gunicorn", "-c", "python:example_app.gunicorn_conf"] +CMD ["gunicorn", "-c", "python:example_app.gunicorn_conf", "--reload"] ## # ci