forked from 3wordchant/capsul-flask
Multi-stage build oh my!
This commit is contained in:
parent
6b53c80a71
commit
6db163365c
28
Dockerfile
28
Dockerfile
@ -1,26 +1,32 @@
|
|||||||
FROM python:3.8-alpine
|
FROM python:3.8-alpine as build
|
||||||
|
|
||||||
RUN apk add gettext git gcc python3-dev musl-dev \
|
RUN apk add gettext git gcc python3-dev musl-dev \
|
||||||
libffi-dev zlib-dev jpeg-dev libjpeg postgresql-dev build-base \
|
libffi-dev zlib-dev jpeg-dev libjpeg postgresql-dev build-base \
|
||||||
--virtual .build-dependencies
|
--virtual .build-dependencies
|
||||||
|
|
||||||
RUN mkdir /code
|
RUN mkdir -p /app/{code,venv}
|
||||||
WORKDIR /code
|
WORKDIR /app/code
|
||||||
COPY Pipfile Pipfile.lock /code/
|
COPY Pipfile Pipfile.lock /app/code/
|
||||||
|
|
||||||
RUN pip install pipenv setuptools wheel cppy
|
RUN python3 -m venv /app/venv
|
||||||
|
RUN pip install pipenv setuptools
|
||||||
|
ENV PATH="/app/venv/bin:$PATH" VIRTUAL_ENV="/app/venv"
|
||||||
|
RUN pip install wheel cppy
|
||||||
|
# Install dependencies into the virtual environment with Pipenv
|
||||||
|
RUN pipenv install --deploy --verbose
|
||||||
|
|
||||||
RUN pipenv install --system --deploy --verbose
|
FROM python:3.8-alpine
|
||||||
|
|
||||||
RUN apk del .build-dependencies \
|
|
||||||
&& rm -rf /var/cache/apk/* /tmp/*
|
|
||||||
|
|
||||||
RUN apk add --no-cache libpq libstdc++ libjpeg
|
RUN apk add --no-cache libpq libstdc++ libjpeg
|
||||||
|
|
||||||
COPY . /code/
|
COPY . /app/code/
|
||||||
|
WORKDIR /app/code
|
||||||
|
|
||||||
|
COPY --from=build /app/venv /app/venv
|
||||||
|
ENV PATH="/app/venv/bin:$PATH" VIRTUAL_ENV="/app/venv"
|
||||||
|
|
||||||
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "-k", "gevent", "--worker-connections", "1000", "app:app"]
|
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "-k", "gevent", "--worker-connections", "1000", "app:app"]
|
||||||
|
|
||||||
VOLUME /code
|
VOLUME /app/code
|
||||||
|
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
@ -6,7 +6,7 @@ services:
|
|||||||
image: 3wordchant/capsul-flask:latest
|
image: 3wordchant/capsul-flask:latest
|
||||||
build: .
|
build: .
|
||||||
volumes:
|
volumes:
|
||||||
- "./:/code"
|
- "./:/app/code"
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- db
|
||||||
ports:
|
ports:
|
||||||
|
Loading…
Reference in New Issue
Block a user