Skip to content

Commit 8f9c690

Browse files
committed
Update build process
1 parent 2d724dc commit 8f9c690

11 files changed

+92
-112
lines changed

Dockerfile

Lines changed: 0 additions & 10 deletions
This file was deleted.

Dockerfile.base

Lines changed: 0 additions & 19 deletions
This file was deleted.

Dockerfile.python

Lines changed: 0 additions & 13 deletions
This file was deleted.

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ mvt-pg-update:
8787

8888
# Docker images
8989
image: ## Build backend:latest image
90-
docker build -t chronmaps/backend:latest .
90+
docker build -t chronmaps/backend:latest -f docker/Dockerfile .
9191

9292
push-image: ## Push backend:latest image
9393
docker push chronmaps/backend:latest
9494

9595
python-image: ## Build image with python dependencies
96-
docker build -t chronmaps/backend:deps-python -f Dockerfile.python .
96+
docker build -t chronmaps/backend:deps-python -f docker/Dockerfile.python .
9797

9898
push-python: ## Push python image
9999
docker push chronmaps/backend:deps-python
@@ -102,8 +102,8 @@ check-python-image:
102102
docker run --entrypoint md5sum chronmaps/backend:deps-python /requirements.txt| sed 's%/%config/%' | md5sum --check -
103103

104104
system-image: ## Build alpine with dependencies
105-
docker build -t chronmaps/backend:deps-base -f Dockerfile.base .
106-
docker build -t chronmaps/backend:deps-build -f Dockerfile.build .
105+
docker build -t chronmaps/backend:deps-base -f docker/Dockerfile.base .
106+
docker build -t chronmaps/backend:deps-build -f docker/Dockerfile.build .
107107

108108
push-system: ## Push alpine with dependencies
109109
docker push chronmaps/backend:deps-base

config/requirements.txt

Lines changed: 0 additions & 25 deletions
This file was deleted.

docker/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM chronmaps/backend:deps-python as python
2+
3+
LABEL maintainer="Mikhail Orlov <[email protected]>"
4+
5+
RUN mkdir /config /src
6+
7+
COPY ./project /src
8+
WORKDIR /src
9+
EXPOSE 80
10+
11+
COPY ./docker/docker-entrypoint.sh /docker-entrypoint.sh
12+
RUN chmod +x /docker-entrypoint.sh
13+
14+
ENTRYPOINT /docker-entrypoint.sh $0 $@
15+
CMD ["gunicorn chron.wsgi -b 0.0.0.0:80 -t 300"]

docker/Dockerfile.base

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM python:3-alpine as base
2+
# chronmaps/backend:deps-base
3+
4+
LABEL maintainer="Mikhail Orlov <[email protected]>"
5+
6+
ENV PYTHONUNBUFFERED=1 \
7+
PYTHONDONTWRITEBYTECODE=1 \
8+
PYTHONFAULTHANDLER=1 \
9+
PYTHONHASHSEED=random \
10+
PIP_NO_CACHE_DIR=off \
11+
PIP_DISABLE_PIP_VERSION_CHECK=on \
12+
PIP_DEFAULT_TIMEOUT=100 \
13+
POETRY_VERSION=1.1.13 \
14+
POETRY_HOME="/opt/poetry" \
15+
POETRY_VIRTUALENVS_IN_PROJECT=true \
16+
POETRY_NO_INTERACTION=1 \
17+
PYSETUP_PATH="/opt/pysetup" \
18+
VENV_PATH="/opt/pysetup/.venv"
19+
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"
20+
21+
ENV ALPINE_MIRROR "http://dl-cdn.alpinelinux.org/alpine"
22+
RUN echo "${ALPINE_MIRROR}/edge/main" >> /etc/apk/repositories
23+
24+
RUN set -ex \
25+
&& apk add --no-cache \
26+
postgresql-libs binutils graphviz \
27+
&& apk add --no-cache --repository ${ALPINE_MIRROR}/edge/community \
28+
gdal-dev geos-dev
29+
30+
ENTRYPOINT /bin/sh

Dockerfile.build renamed to docker/Dockerfile.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ FROM chronmaps/backend:deps-base as base
44
LABEL maintainer="Mikhail Orlov <[email protected]>"
55

66
RUN set -ex \
7-
&& apk add --no-cache \
8-
alpine-sdk libressl postgresql-dev linux-headers pcre-dev \
7+
&& apk add --no-cache \
8+
postgresql-dev linux-headers pcre-dev gcc musl-dev libffi-dev alpine-sdk libressl zlib-dev jpeg-dev \
99
&& apk add --no-cache --repository ${ALPINE_MIRROR}/edge/community \
1010
proj-dev
1111

docker/Dockerfile.python

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM chronmaps/backend:deps-build as build
2+
# chronmaps/backend:deps-python
3+
4+
LABEL maintainer="Mikhail Orlov <[email protected]>"
5+
6+
RUN pip install "poetry==$POETRY_VERSION"
7+
8+
WORKDIR $PYSETUP_PATH
9+
COPY pyproject.toml poetry.lock ./
10+
RUN poetry install
11+
12+
# TODO: create dev stage that runs linting etc, --no-dev in production
13+
14+
FROM chronmaps/backend:deps-base as prod
15+
16+
COPY --from=build $VENV_PATH $VENV_PATH
17+
18+
ENTRYPOINT /bin/sh

docker/docker-entrypoint.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/ash
2+
3+
set -e
4+
5+
dbname=$POSTGRES_DB
6+
host="db"
7+
port="5432"
8+
user=$POSTGRES_USER
9+
passwd=$POSTGRES_PASSWORD
10+
11+
. /opt/pysetup/.venv/bin/activate
12+
13+
>&2 echo "Waiting for Postgres..."
14+
15+
python wait_for_pg.py $dbname $host $port $user $passwd
16+
17+
>&2 echo "Postgres is up - executing command"
18+
19+
python manage.py makemigrations
20+
python manage.py migrate
21+
python manage.py collectstatic --noinput
22+
23+
exec "$@"

project/init.sh

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)