Skip to content
This repository was archived by the owner on Dec 7, 2021. It is now read-only.

Commit 04d274e

Browse files
committed
Nginx for development mode
Add nginx to serve the generated static site and use that rather than mkdocs' build in development mode server. This is being done because the i18n plugin that we are going to be trying out does not work with the dev server.
1 parent 1e2e6ed commit 04d274e

File tree

6 files changed

+67
-8
lines changed

6 files changed

+67
-8
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
!.git/refs/heads/*
1010
!.pipeline
1111
!COPYING
12+
!contrib
13+
contrib/*
14+
!contrib/nginx
1215
!docs
1316
!poetry.lock
1417
!pyproject.toml

.pipeline/blubber.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,11 @@ variants:
4545
- from: local
4646
source: .
4747
destination: .
48+
49+
local:
50+
# Local development container
51+
includes:
52+
- dev-python
53+
apt:
54+
packages:
55+
- nginx-light
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Dockerfile for *local development*.
22
# Generated by Blubber from .pipeline/blubber.yaml
3-
FROM docker-registry.wikimedia.org/python3-buster:latest AS dev-python
3+
FROM docker-registry.wikimedia.org/python3-buster:latest AS local
44
USER 0
55
ENV HOME="/root"
66
ENV DEBIAN_FRONTEND="noninteractive"
7-
RUN apt-get update && apt-get install -y "gettext" "git" "python3-dev" "python3-venv" && rm -rf /var/lib/apt/lists/*
7+
RUN apt-get update && apt-get install -y "gettext" "git" "python3-dev" "python3-venv" "nginx-light" && rm -rf /var/lib/apt/lists/*
88
RUN python3 "-m" "easy_install" "pip" && python3 "-m" "pip" "install" "-U" "setuptools" "wheel" "tox" "pip"
99
ENV POETRY_VIRTUALENVS_PATH="/opt/lib/poetry"
1010
RUN python3 "-m" "pip" "install" "-U" "poetry==1.1.11"
@@ -19,4 +19,4 @@ RUN mkdir -p "/opt/lib/poetry"
1919
RUN poetry "install" "--no-root"
2020
COPY --chown=65533:65533 [".", "."]
2121

22-
LABEL blubber.variant="dev-python" blubber.version="0.8.0+a6bf87e"
22+
LABEL blubber.variant="local" blubber.version="0.8.0+a6bf87e"

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ this := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
2020
PROJECT_DIR := $(dir $(this))
2121
PIPELINE_DIR := $(PROJECT_DIR)/.pipeline
2222
BLUBBEROID := https://blubberoid.wikimedia.org
23-
DOCKERFILES := $(PIPELINE_DIR)/dev-python.Dockerfile
23+
DOCKERFILES := $(PIPELINE_DIR)/local.Dockerfile
2424

2525
help:
2626
@echo "Make targets:"
@@ -52,6 +52,11 @@ tail: ## Tail logs from the docker-compose stack
5252
docker compose logs -f
5353
.PHONY: tail
5454

55+
build: ## Build static site
56+
docker compose exec portal \
57+
poetry run mkdocs --verbose build
58+
.PHONY: tail
59+
5560
clean: ## Clean up Docker images and containers
5661
yes | docker image prune
5762
yes | docker container prune

contrib/nginx/nginx.conf

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
daemon off;
2+
user runuser runuser;
3+
worker_processes auto;
4+
pid /tmp/nginx.pid;
5+
6+
error_log /dev/stderr info;
7+
8+
events {
9+
worker_connections 768;
10+
}
11+
12+
http {
13+
include /etc/nginx/mime.types;
14+
default_type application/octet-stream;
15+
access_log /dev/stderr;
16+
17+
client_body_temp_path "/tmp" 1 2;
18+
proxy_temp_path "/tmp" 1 2;
19+
fastcgi_temp_path "/tmp" 1 2;
20+
scgi_temp_path "/tmp" 1 2;
21+
uwsgi_temp_path "/tmp" 1 2;
22+
23+
sendfile on;
24+
tcp_nopush on;
25+
tcp_nodelay off;
26+
gzip on;
27+
keepalive_timeout 65;
28+
types_hash_max_size 2048;
29+
server_tokens off;
30+
31+
32+
33+
index index.html;
34+
35+
server {
36+
listen 9000;
37+
root /srv/app/site;
38+
}
39+
}

docker-compose.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ services:
44
portal:
55
build:
66
context: .
7-
dockerfile: .pipeline/dev-python.Dockerfile
8-
image: "wmdevportal:dev-python"
7+
dockerfile: .pipeline/local.Dockerfile
8+
image: "wmdevportal:local"
99
user: somebody
1010
working_dir: /srv/app
11-
command: >
12-
poetry run mkdocs serve --dev-addr 0.0.0.0:9000
11+
command:
12+
- bash
13+
- -c
14+
- >-
15+
poetry run mkdocs --verbose build &&
16+
exec nginx -c /srv/app/contrib/nginx/nginx.conf
1317
volumes:
1418
- type: bind
1519
source: .

0 commit comments

Comments
 (0)