Verified Commit f55af423 authored by Joakim Saario's avatar Joakim Saario
Browse files

WIP: Docker setup

parent 4a39edd2
Pipeline #8001 passed with stage
in 2 minutes and 54 seconds
/aurweb.sqlite3
FROM archlinux
COPY . /aurweb
WORKDIR /aurweb
# Install dependencies. Note that they are split up in multiple layers to speed
# up the build process when rebuilding the image. Dependencies are grouped
# together by compontent and those that are more unlikely to change are
# installed in earlier layers.
# Install NGINX
RUN pacman -Syu --noconfirm nginx
# Install database
RUN pacman -Syu --noconfirm percona-server percona-server-clients
# Install PHP dependencies
RUN pacman -Syu --noconfirm php
# Install keycloak
RUN pacman -Syu --noconfirm keycloak
# Install dependencies.
RUN pacman -Syu --noconfirm base-devel git gpgme protobuf pyalpm \
......@@ -12,20 +27,24 @@ RUN pacman -Syu --noconfirm base-devel git gpgme protobuf pyalpm \
python-pytest-asyncio python-coverage hypercorn python-bcrypt \
python-email-validator openssh python-lxml
# Remove aurweb.sqlite3 if it was copied over via COPY.
RUN rm -fv aurweb.sqlite3
WORKDIR /aurweb
COPY . .
ENV AUR_CONFIG conf/config
# Setup our test config.
RUN sed -r "s;YOUR_AUR_ROOT;/aurweb;g" conf/config.dev > conf/config
RUN sed -r 's;YOUR_AUR_ROOT;/aurweb;g' conf/config.dev | \
sed -r '/sqlite/d' | \
sed -r '/backend/ s/^;//' | \
sed -r 's/^(backend).*/\1 = mysql/' | \
sed -r '/host/ s/^;//' | \
sed -r 's/^(host).*/\1 = mysql/' | \
sed -r '/name/ s/^;//' | \
sed -r 's/^(name).*/\1 = aurweb/' | \
sed -r '/user/ s/^;//' | \
sed -r 's/^(user).*/\1 = root/' | \
sed -r '/password/ s/^;//' | \
sed -r 's/^(password).*/\1 =/' > "${AUR_CONFIG}"
# Install translations.
RUN AUR_CONFIG=conf/config make -C po all install
# Initialize the database.
RUN AUR_CONFIG=conf/config python -m aurweb.initdb
# Test everything!
RUN make -C test
# Produce a coverage report.
RUN coverage report --include='aurweb/*'
RUN make -C po all install
AUR_WEB=conf/config
.PHONY: test
test: aurweb.sqlite3
# Test everything!
make -C test
# Produce a coverage report.
coverage report --include='aurweb/*'
aurweb.sqlite3:
python -m aurweb.initdb
# Docker wrappers
define docker
docker-compose run \
--rm \
--entrypoint $(1) \
aurweb-fastapi \
$(2)
endef
define docker-make
$(call docker,make,$(1))
endef
.PHONY: docker-test
docker-test:
$(call docker-make,test)
version: "3.8"
services:
aurweb-fastapi:
build: .
image: aurweb:latest
init: true
command: python -u -m hypercorn -b 0.0.0.0:8082 aurweb.asgi:app
ports:
- 8082:8082
aurweb-php:
image: aurweb:latest
init: true
command: php -S 0.0.0.0:8081 -t /aurweb/web/html
ports:
- 8081:8081
nginx:
image: aurweb:latest
init: true
environment:
NGINX_CONFIG: |
events {}
daemon off;
error_log /dev/stderr info;
pid /run/nginx.pid;
http {
access_log /dev/stdout;
server {
listen 8080;
location / {
proxy_pass http://aurweb-php:8081;
}
location /sso {
proxy_pass http://aurweb-fastapi:8082;
}
}
}
command: >-
/bin/sh -c 'printf "%s\n" "$$NGINX_CONFIG" > /etc/nginx/nginx.conf && exec nginx'
ports:
- 8080:8080
mysql:
image: aurweb:latest
init: true
working_dir: /var/lib/mysql
command: >-
/bin/sh -c '
mkdir -p /var/lib/mysql{,-files} /run/mysqld &&
chown mysql:mysql /var/lib/mysql{,-files} /run/mysqld &&
mysqld_pre_systemd && exec mysqld --user=mysql --skip-grant-tables
'
volumes:
- mysql_data:/var/lib/mysql
keycloak:
image: aurweb:latest
init: true
command: /opt/keycloak/bin/standalone.sh -Djboss.bind.address=0.0.0.0 -Djboss.http.port=8083
volumes:
- keycloak_data:/opt/keycloak/standalone/data
ports:
- 8083:8083
volumes:
mysql_data: {}
keycloak_data: {}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment