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
3 changed files with 66 additions and 0 deletions
Showing only changes of commit f8e9ab2482 - Show all commits

14
.drone.yml Normal file
View File

@ -0,0 +1,14 @@
---
kind: pipeline
name: publish docker image
steps:
- name: build and publish
image: plugins/docker
settings:
username:
from_secret: docker_reg_username_3wc
password:
from_secret: docker_reg_passwd_3wc
repo: 3wordchant/capsul-flask
tags: latest
3wordchant marked this conversation as resolved Outdated

Off-topic: does capsul do tagged releases? That'd be handy as the plugins/docker plugin has a auto_tag: true which generates the image tag based on the git tag. That is probably One For Later ™️

Off-topic: does capsul do tagged releases? That'd be handy as the [plugins/docker](http://plugins.drone.io/drone-plugins/drone-docker/) plugin has a `auto_tag: true` which generates the image tag based on the git tag. That is probably One For Later :tm:

The last one was a year ago, I think, probably worth asking Cyberia if they'd be down for that?

Even more off-topic: can auto_tag: true work off the branch name? I'd love a way to be able to publish different images from different branches without hardcoding the branch name.

The last one was a year ago, I think, probably worth asking Cyberia if they'd be down for that? Even more off-topic: can `auto_tag: true` work off the branch name? I'd love a way to be able to publish different images from different branches without hardcoding the branch name.

auto_tag doesn't, but I think it's possible with interpolating e.g. ${DRONE_COMMIT_BRANCH}, see 982556a

`auto_tag` doesn't, but I think it's possible with interpolating e.g. `${DRONE_COMMIT_BRANCH}`, see 982556a

26
Dockerfile Normal file
View File

@ -0,0 +1,26 @@
FROM python:3.8-alpine
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 pip install pipenv setuptools wheel cppy
RUN pipenv install --system --deploy --verbose
RUN apk del .build-dependencies \
&& rm -rf /var/cache/apk/* /tmp/*
RUN apk add --no-cache libpq libstdc++ libjpeg
COPY . /code/
3wordchant marked this conversation as resolved Outdated
Same totally optional comment as https://git.autonomic.zone/3wordchant/capsul-flask/pulls/2/files#issuecomment-7607.
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "-k", "gevent", "--worker-connections", "1000", "app:app"]
VOLUME /code
EXPOSE 5000

26
docker-compose.yml Normal file
View File

@ -0,0 +1,26 @@
---
version: "3.8"
services:
app:
image: 3wordchant/capsul-flask:latest
build: .
volumes:
- "./:/code"
depends_on:
- db
ports:
- "5000:5000"
environment:
- "POSTGRES_CONNECTION_PARAMETERS=host=db port=5432 user=capsul password=capsul dbname=capsul"
db:
image: "postgres:9.6.5"
volumes:
- "postgres:/var/lib/postgresql/data"
environment:
POSTGRES_USER: capsul
POSTGRES_PASSWORD: capsul
POSTGRES_DB: capsul
volumes:
postgres: