Add Dockefile for the application and demo database

This commit is contained in:
jordi fita mas 2023-01-18 14:43:10 +01:00
commit 28121cb3c6
4 changed files with 84 additions and 0 deletions

40
docker-compose.yml Normal file
View File

@ -0,0 +1,40 @@
---
version: "3"
networks:
numerus:
driver: bridge
services:
app:
build:
args:
user: numerus
uid: 1000
context: numerus/
dockerfile: Dockerfile
restart: unless-stopped
environment:
- PGHOST=db
- PGUSER=numerus
- PGPASSWORD=numerus
- PGDATABASE=numerus
ports:
- '8083:8080'
networks:
- numerus
depends_on:
- db
db:
build:
context: postgres/
dockerfile: Dockerfile
restart: always
environment:
- POSTGRES_DB=numerus
- POSTGRES_PASSWORD=postgres
- NUMERUS_USER=numerus
- NUMERUS_PASSWORD=numerus
networks:
- numerus

19
numerus/Dockerfile Normal file
View File

@ -0,0 +1,19 @@
FROM debian:bullseye
RUN set -eux \
&& apt-get update \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get install -y curl gpg \
&& curl https://build.opensuse.org/projects/home:jfita:numerus/public_key | gpg --dearmor -o /etc/apt/trusted.gpg.d/obs-numerus.gpg \
&& echo 'deb [signed-by=/etc/apt/trusted.gpg.d/obs-numerus.gpg] http://download.opensuse.org/repositories/home:/jfita:/numerus/Debian_11/ ./' >> /etc/apt/sources.list.d/numerus.list \
&& apt-get remove --purge -y curl gpg \
&& apt-get autoremove --purge -y \
&& apt-get update \
&& apt-get install -y numerus \
&& apt-get clean
EXPOSE 8080
WORKDIR /usr/share/numerus
CMD ["numerus"]

16
postgres/Dockerfile Normal file
View File

@ -0,0 +1,16 @@
FROM postgres:14-bullseye
RUN set -eux \
&& apt-get update \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get install -y curl gpg \
&& curl https://build.opensuse.org/projects/home:jfita:numerus/public_key | gpg --dearmor -o /etc/apt/trusted.gpg.d/obs-numerus.gpg \
&& echo 'deb [signed-by=/etc/apt/trusted.gpg.d/obs-numerus.gpg] http://download.opensuse.org/repositories/home:/jfita:/numerus/Debian_11/ ./' >> /etc/apt/sources.list.d/numerus.list \
&& apt-get remove --purge -y curl gpg \
&& apt-get autoremove --purge -y \
&& apt-get update \
&& apt-get install -y numerus-sqitch numerus-demo \
&& ln /usr/share/numerus/demo.sql /docker-entrypoint-initdb.d/01-demo.sql \
&& apt-get clean
COPY deploy.sh /docker-entrypoint-initdb.d/00-deploy.sh

9
postgres/deploy.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
set -e
cd /usr/share/numerus/sqitch
PGUSER="$POSTGRES_USER" PGDATABASE="$POSTGRES_DB" sqitch deploy
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE ROLE "${NUMERUS_USER:-numerus}" LOGIN PASSWORD '${NUMERUS_PASSWORD:-numerus}' IN ROLE authenticator
EOSQL