Browse Source

dockerize

pull/230/head
Timothée Oliger 6 years ago
parent
commit
8390ff12c9
No known key found for this signature in database GPG Key ID: 19E0C7042397EC61
3 changed files with 89 additions and 0 deletions
  1. +54
    -0
      Dockerfile
  2. +27
    -0
      README.md
  3. +8
    -0
      uwsgi.ini

+ 54
- 0
Dockerfile View File

@ -0,0 +1,54 @@
ARG BUILD_DATE=""
ARG ARCH=amd64
ARG PYTHON_VERSION=3
# First stage
FROM docker.io/${ARCH}/python:${PYTHON_VERSION}-alpine3.8 as builder
# Install deps
COPY requirements.txt /tmp
RUN apk add --no-cache \
build-base \
postgresql-dev \
linux-headers
RUN pip install --prefix="/install" --no-warn-script-location -r /tmp/requirements.txt \
braintree \
uWSGI
## Second stage
FROM docker.io/${ARCH}/python:${PYTHON_VERSION}-alpine3.8
ENV DEBUG False
ENV DB_NAME /data/hc.sqlite
RUN apk add --no-cache libpq \
mailcap
RUN addgroup -g 900 -S healthchecks && \
adduser -u 900 -S healthchecks -G healthchecks
WORKDIR /app
COPY --from=builder /install /usr/local
COPY . .
RUN ./manage.py collectstatic --noinput && \
./manage.py compress
RUN mkdir /data && chown healthchecks:healthchecks /data
VOLUME /data
USER healthchecks
EXPOSE 8000/tcp
ARG SYNAPSE_VERSION
ARG PYTHON_VERSION
ARG BUILD_DATE
CMD ["uwsgi", "--enable-threads", "uwsgi.ini"]

+ 27
- 0
README.md View File

@ -281,6 +281,33 @@ test them on a copy of your database, not on the live database right away.
In a production setup, you should also have regular, automated database
backups set up.
## Deployment
### Docker
To run the app, you can:
$ docker build -t healthchecks:latest .
$ docker volume create \
--driver local \
--opt type=tmpfs \
--opt device=tmpfs \
--opt o=uid=900,gid=900 \
healthchecks
$ docker run -d \
--name healthchecks \
--mount source=healthchecks,target=/data \
-p 8000:8000 \
healthchecks:latest
to migrate the db:
$ docker exec healthchecks ./manage.py migrate
## Integrations
### Discord


+ 8
- 0
uwsgi.ini View File

@ -0,0 +1,8 @@
[uwsgi]
http-socket = :8000
enable-threads
plugin = python3
module = hc.wsgi:application
static-map = /static=static-collected
static-gzip-dir = static-collected/CACHE
attach-daemon = ./manage.py sendalerts

Loading…
Cancel
Save