From ad7c400ceb6e5534314094ec8b1d67f94455c200 Mon Sep 17 00:00:00 2001 From: mxmehl Date: Wed, 4 May 2022 14:37:03 +0200 Subject: [PATCH] provide possibility to locally build website with all required steps --- Dockerfile | 47 ++++++++++++++++++++++++++++++++++++++++-- docker-compose.dev.yml | 29 ++++++++++++++++++++++++++ docker-compose.yml | 4 +++- 3 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 docker-compose.dev.yml diff --git a/Dockerfile b/Dockerfile index 7e353252..75fd348a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,11 +2,54 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -FROM bitnami/apache:2.4 +# ============================================================================= +# Configure webserver +# ============================================================================= -COPY site/public/ /app/ +FROM bitnami/apache:2.4 as webserver-prep COPY reuse.software.conf /vhosts/ ## Enable mod_expires module RUN sed -i -r 's/#LoadModule expires_module/LoadModule expires_module/' /opt/bitnami/apache/conf/httpd.conf + + +# ============================================================================= +# Production (use the site built in hugo step in .drone.yml) +# ============================================================================= + +FROM webserver-prep as production + +COPY site/public/ /app/ + + +# ============================================================================= +# Development Preparation: run sync-docs, po4a and hugo +# ============================================================================= + +FROM alpine:3 as dev-prep + +# Dependencies +RUN apk --no-cache add bash perl-yaml-tiny po4a hugo + +COPY . /app + +WORKDIR /app/ + +# sync and translate docs (from their own po files) +RUN bash sync-docs.sh + +# Run po4a for reuse-website po strings +RUN cd site/ && po4a po/po4a.conf + +# Build hugo +RUN hugo -s site + + +# ============================================================================= +# Production (use the site built in dev-prep) +# ============================================================================= + +FROM webserver-prep as development + +COPY --from=dev-prep /app/site/public/ /app/ diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 00000000..2d439113 --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,29 @@ +# SPDX-FileCopyrightText: Free Software Foundation Europe e.V. +# +# SPDX-License-Identifier: GPL-3.0-or-later + +# ============================================================================= +# sync docs, translate, and build hugo in Docker container +# ============================================================================= + +version: "3" +services: + reuse-web: + container_name: reuse-web + build: + context: . + target: development + image: reuse-web + restart: always + logging: + driver: json-file + options: + max-size: "5m" + max-file: "5" + # Reverse Proxy + labels: + proxy.host: "reuse.software" + proxy.host_alias: "www.reuse.software" + proxy.port: "6140" + ports: + - "6140:8080" diff --git a/docker-compose.yml b/docker-compose.yml index 909ca2c9..f91412f3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,9 @@ version: "3" services: reuse-web: container_name: reuse-web - build: . + build: + context: . + target: production image: reuse-web restart: always logging: