Initial docker-compose setup

This commit is contained in:
Víðir Valberg Guðmundsson 2021-07-29 11:31:45 +02:00
parent db7d4909c7
commit b5dd97e935
4 changed files with 72 additions and 0 deletions

35
docker/Dockerfile Normal file
View file

@ -0,0 +1,35 @@
FROM python:3.7-slim-buster
ENV PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONHASHSEED=random \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100
WORKDIR /app
ADD src/requirements/ /tmp/
RUN apt-get update \
&& apt-get install -y \
build-essential \
binutils \
python3-dev \
python3-pip \
python3-setuptools \
python3-cffi \
libxslt-dev \
libxml2-dev \
libxmlsec1-dev \
libpq-dev \
libjpeg-dev \
libgdal-dev \
wkhtmltopdf
RUN pip3 install --no-cache-dir -r /tmp/dev.txt
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www
#COPY --chown=www:www ./ /app/

30
docker/docker-compose.yml Normal file
View file

@ -0,0 +1,30 @@
version: '3.7'
services:
app:
image: app
build:
context: ../
dockerfile: docker/Dockerfile
ports:
- "8000:8000"
tty: true
stdin_open: true
command: python src/manage.py runserver 0.0.0.0:8000
volumes:
- ..:/app
environment:
- DJANGO_DATABASE_NAME=postgres
- DJANGO_DATABASE_USER=postgres
- DJANGO_DATABASE_PASSWORD=postgres
- DJANGO_DATABASE_HOST=db
- DJANGO_DATABASE_PORT=5432
links:
- db
db:
build:
context: postgis_container
environment:
POSTGRES_USER: 'postgres'
POSTGRES_PASSWORD: 'postgres'
ports:
- 5432:5432

View file

@ -0,0 +1,4 @@
#!/bin/bash
set -e
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname template1 -c "create extension btree_gist"

View file

@ -0,0 +1,3 @@
FROM postgis/postgis:latest
COPY 00-create-extensions.sh /docker-entrypoint-initdb.d/