Merge pull request #115 from sartography/backend/improve-dockerfile
backend: avoid redundant steps in Dockerfile
This commit is contained in:
commit
53fc687a54
|
@ -1,28 +1,35 @@
|
||||||
FROM ghcr.io/sartography/python:3.11
|
# Base image to share ENV vars that activate VENV.
|
||||||
|
FROM ghcr.io/sartography/python:3.11 AS base
|
||||||
|
|
||||||
|
ENV VIRTUAL_ENV=/app/venv
|
||||||
|
RUN python3 -m venv $VIRTUAL_ENV
|
||||||
|
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Setup image for installing Python dependencies.
|
||||||
|
FROM base AS setup
|
||||||
|
|
||||||
RUN pip install poetry
|
RUN pip install poetry
|
||||||
RUN useradd _gunicorn --no-create-home --user-group
|
RUN useradd _gunicorn --no-create-home --user-group
|
||||||
|
|
||||||
RUN apt-get update && \
|
RUN apt-get update \
|
||||||
apt-get install -y -q \
|
&& apt-get install -y -q gcc libssl-dev libpq-dev
|
||||||
gcc libssl-dev \
|
|
||||||
curl git-core libpq-dev \
|
|
||||||
gunicorn3 default-mysql-client
|
|
||||||
|
|
||||||
WORKDIR /app
|
COPY . /app
|
||||||
COPY pyproject.toml poetry.lock /app/
|
|
||||||
RUN poetry install --without dev
|
RUN poetry install --without dev
|
||||||
|
|
||||||
RUN set -xe \
|
# Final image without setup dependencies.
|
||||||
&& apt-get remove -y gcc python3-dev libssl-dev \
|
FROM base AS final
|
||||||
&& apt-get autoremove -y \
|
|
||||||
&& apt-get clean -y \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
COPY . /app/
|
LABEL source="https://github.com/sartography/spiff-arena"
|
||||||
|
LABEL description="Software development platform for building, running, and monitoring executable diagrams"
|
||||||
|
|
||||||
# run poetry install again AFTER copying the app into the image
|
RUN apt-get update \
|
||||||
# otherwise it does not know what the main app module is
|
&& apt-get clean -y \
|
||||||
RUN poetry install --without dev
|
&& apt-get install -y -q curl git-core gunicorn3 default-mysql-client \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
CMD ./bin/boot_server_in_docker
|
COPY --from=setup /app /app
|
||||||
|
|
||||||
|
ENTRYPOINT ["./bin/boot_server_in_docker"]
|
||||||
|
|
Loading…
Reference in New Issue