Docker image, & local development docker-compose.yml #2

Merged
3wordchant merged 12 commits from docker into master 2021-07-21 23:18:11 +00:00
2 changed files with 18 additions and 12 deletions
Showing only changes of commit 5cd5126039 - Show all commits

View File

@ -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 \
3wordchant marked this conversation as resolved Outdated

Feel free to ignore but I usually add --no-cache to save space and newline + sort things so it is easier to have a visual overview of dependencies and alphabetic ordering to know where to slot things in. Can be useful if you end up adding a lot of dependencies and then need to remove them over time as the software changes.

RUN apk add --no-cache \
    build-base \
    gcc \
    gettext \
    git \
    jpeg-dev \
    libffi-dev \
    libjpeg \
    musl-dev \
    postgresql-dev \
    python3-dev \
    zlib-dev \
    --virtual .build-dependencies
Feel free to ignore but I usually add `--no-cache` to save space and newline + sort things so it is easier to have a visual overview of dependencies and alphabetic ordering to know where to slot things in. Can be useful if you end up adding a lot of dependencies and then need to remove them over time as the software changes. ``` RUN apk add --no-cache \ build-base \ gcc \ gettext \ git \ jpeg-dev \ libffi-dev \ libjpeg \ musl-dev \ postgresql-dev \ python3-dev \ zlib-dev \ --virtual .build-dependencies ```
libffi-dev zlib-dev jpeg-dev libjpeg postgresql-dev build-base \
--virtual .build-dependencies
RUN mkdir /code
WORKDIR /code
COPY Pipfile Pipfile.lock /code/
RUN mkdir -p /app/{code,venv}
WORKDIR /app/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
RUN apk del .build-dependencies \
&& rm -rf /var/cache/apk/* /tmp/*
FROM python:3.8-alpine
RUN apk add --no-cache libpq libstdc++ libjpeg
3wordchant marked this conversation as resolved Outdated
Same totally optional comment as https://git.autonomic.zone/3wordchant/capsul-flask/pulls/2/files#issuecomment-7607.
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"]
VOLUME /code
VOLUME /app/code
EXPOSE 5000

View File

@ -6,7 +6,7 @@ services:
image: 3wordchant/capsul-flask:latest
build: .
volumes:
- "./:/code"
- "./:/app/code"
depends_on:
- db
ports: