Skip to content

Commit 21521c3

Browse files
committed
ci: Complete dev container configuration (#3052)
1 parent 15c65ef commit 21521c3

File tree

15 files changed

+346
-488
lines changed

15 files changed

+346
-488
lines changed

.devcontainer/devcontainer.json

Lines changed: 101 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,105 @@
11
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
22
// README at: https://github.com/devcontainers/templates/tree/main/src/python
33
{
4-
"name": "Privacy Guides",
5-
"image": "ghcr.io/squidfunk/mkdocs-material:9.5.17",
6-
"forwardPorts": [8000],
7-
"postCreateCommand": "git submodule init; git submodule update theme/assets/brand; apk add bash; /bin/bash run.sh --cmd=mkdocs --cmd_flags=--dev-addr=0.0.0.0:8000"
4+
"name": "Privacy Guides",
5+
"build": {
6+
"dockerfile": "../Dockerfile"
7+
},
8+
"overrideCommand": true,
9+
"containerEnv": {
10+
"MAIN_SITE_BASE_URL": "http://127.0.0.1:8000/en/",
11+
"MAIN_SITE_ABOUT_URL": "http://127.0.0.1:8000/en/about/",
12+
"MAIN_SITE_RECOMMENDATIONS_URL": "http://127.0.0.1:8000/en/tools/",
13+
"MAIN_SITE_KNOWLEDGE_BASE_URL": "http://127.0.0.1:8000/en/basics/why-privacy-matters/",
14+
"ARTICLES_SITE_BASE_URL": "http://127.0.0.1:8001/articles/",
15+
"VIDEOS_SITE_BASE_URL": "http://127.0.0.1:8002/videos/"
16+
},
17+
"forwardPorts": [8000, 8001, 8002],
18+
"mounts": [
19+
"source=${env:HOME}${env:USERPROFILE}/.config,target=/root/.config,type=bind"
20+
],
21+
"customizations": {
22+
"vscode": {
23+
"settings": {
24+
"tasks": {
25+
"version": "2.0.0",
26+
"tasks": [
27+
{
28+
"label": "Articles",
29+
"type": "shell",
30+
"command": "mkdocs serve --config-file=mkdocs.blog.yml --dev-addr=localhost:8001",
31+
"group": "test",
32+
"runOptions": {
33+
"runOn": "folderOpen"
34+
},
35+
"presentation": {
36+
"reveal": "always",
37+
"panel": "dedicated",
38+
"group": "Live server"
39+
}
40+
},
41+
{
42+
"label": "Videos",
43+
"type": "shell",
44+
"command": "mkdocs serve --config-file=mkdocs.videos.yml --dev-addr=localhost:8002",
45+
"group": "test",
46+
"runOptions": {
47+
"runOn": "folderOpen"
48+
},
49+
"presentation": {
50+
"reveal": "always",
51+
"panel": "dedicated",
52+
"group": "Live server"
53+
}
54+
},
55+
{
56+
"label": "Main",
57+
"type": "shell",
58+
"command": "./run.sh --cmd=mkdocs --insiders --production",
59+
"group": "test",
60+
"runOptions": {
61+
"runOn": "folderOpen"
62+
},
63+
"presentation": {
64+
"reveal": "always",
65+
"panel": "dedicated",
66+
"group": "Live server"
67+
}
68+
}
69+
]
70+
}
71+
},
72+
"extensions": [
73+
"EditorConfig.EditorConfig",
74+
"DavidAnson.vscode-markdownlint",
75+
"wholroyd.jinja",
76+
"mikestead.dotenv",
77+
"redhat.vscode-yaml",
78+
"ecmel.vscode-html-css",
79+
"yzhang.markdown-all-in-one",
80+
"bierner.markdown-checkbox",
81+
"bierner.markdown-emoji",
82+
"bierner.markdown-footnotes",
83+
"bierner.markdown-preview-github-styles",
84+
"esbenp.prettier-vscode",
85+
"ltex-plus.vscode-ltex-plus",
86+
"ms-python.python",
87+
"github.vscode-github-actions"
88+
]
89+
},
90+
"codespaces": {
91+
"repositories": {
92+
"privacyguides/mkdocs-material-insiders": {
93+
"permissions": {
94+
"content": "read"
95+
}
96+
},
97+
"privacyguides/brand": {
98+
"permissions": {
99+
"content": "read"
100+
}
101+
}
102+
}
103+
}
104+
}
8105
}

.devcontainer/team/devcontainer.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@ jobs:
5757
echo "EXTRA_FLAGS=""$EXTRA_FLAGS" --production""
5858
} >> "$GITHUB_ENV"
5959
60+
- name: Set base navigation URLs for production build
61+
if: inputs.context == 'production'
62+
run: |
63+
{
64+
echo "MAIN_SITE_BASE_URL=https://www.privacyguides.org/en/"
65+
echo "MAIN_SITE_ABOUT_URL=https://www.privacyguides.org/en/about/"
66+
echo "MAIN_SITE_RECOMMENDATIONS_URL=https://www.privacyguides.org/en/tools/"
67+
echo "MAIN_SITE_KNOWLEDGE_BASE_URL=https://www.privacyguides.org/en/basics/why-privacy-matters/"
68+
echo "ARTICLES_SITE_BASE_URL=https://www.privacyguides.org/articles/"
69+
echo "VIDEOS_SITE_BASE_URL=https://www.privacyguides.org/videos/"
70+
} >> "$GITHUB_ENV"
71+
6072
- name: Set Metadata for Privileged Builds
6173
if: inputs.privileged
6274
run: |

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
url = https://github.com/privacyguides/brand.git
44
[submodule "modules/mkdocs-material"]
55
path = modules/mkdocs-material
6-
url = git@github.com:privacyguides/mkdocs-material-insiders.git
6+
url = https://github.com/privacyguides/mkdocs-material-insiders.git

.vscode/extensions.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@
2727
"redhat.vscode-yaml",
2828
"ecmel.vscode-html-css",
2929
"yzhang.markdown-all-in-one",
30-
"valentjn.vscode-ltex",
3130
"bierner.markdown-checkbox",
3231
"bierner.markdown-emoji",
3332
"bierner.markdown-footnotes",
3433
"bierner.markdown-preview-github-styles",
35-
"esbenp.prettier-vscode"
34+
"esbenp.prettier-vscode",
35+
"ltex-plus.vscode-ltex-plus",
36+
"ms-python.python",
37+
"github.vscode-github-actions"
3638
]
3739
}

Dockerfile

Lines changed: 47 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,68 @@
1-
FROM python:3.13-alpine as base
1+
FROM python:3.12-bookworm AS base
22

33
LABEL org.opencontainers.image.source="https://github.com/privacyguides/privacyguides.org"
44

5-
# Setup env
6-
ENV LANG C.UTF-8
7-
ENV LC_ALL C.UTF-8
8-
ENV PYTHONDONTWRITEBYTECODE 1
9-
ENV PYTHONFAULTHANDLER 1
5+
# Setup environment
6+
ENV LANG=C.UTF-8
7+
ENV LC_ALL=C.UTF-8
8+
ENV PYTHONDONTWRITEBYTECODE=1
9+
ENV PYTHONFAULTHANDLER=1
1010

11+
####################################################
12+
# Stage: python-deps
13+
# Install pipenv and compilation dependencies
14+
####################################################
1115
FROM base AS python-deps
1216

13-
# Install pipenv and compilation dependencies
14-
RUN pip install pipenv
15-
RUN \
16-
apk upgrade --update-cache -a \
17-
&& \
18-
apk add --no-cache \
19-
gcc \
20-
libffi-dev \
21-
musl-dev
17+
# Install pipenv
18+
RUN pip install --no-cache-dir pipenv
19+
20+
# Install build tools and libraries needed to compile any Python packages
21+
RUN apt-get update && \
22+
apt-get install -y --no-install-recommends \
23+
gcc \
24+
libffi-dev \
25+
build-essential \
26+
&& rm -rf /var/lib/apt/lists/*
2227

23-
# Install python dependencies in /.venv
28+
# Copy Pipfile, Pipfile.lock, and any local modules needed for dependency resolution
2429
COPY modules/mkdocs-material ./modules/mkdocs-material
2530
COPY Pipfile .
2631
COPY Pipfile.lock .
32+
33+
# Install all Python dependencies into a project‐local virtual environment at /.venv
2734
RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy
2835

36+
####################################################
37+
# Stage: runtime
38+
# Install runtime dependencies and copy runtime artifacts
39+
####################################################
2940
FROM base AS runtime
3041

31-
# Install runtime dependencies
32-
RUN \
33-
apk upgrade --update-cache -a \
34-
&& \
35-
apk add --no-cache \
36-
cairo \
37-
freetype-dev \
38-
git \
39-
git-fast-import \
40-
jpeg-dev \
41-
openssh \
42-
pngquant \
43-
tini \
44-
zlib-dev \
45-
libffi-dev \
46-
musl-dev \
47-
bash
42+
# Install runtime packages (GTK/Cairo, image processing libraries, Git, etc.)
43+
RUN apt-get update && \
44+
apt-get install -y --no-install-recommends \
45+
libcairo2-dev \
46+
libfreetype6-dev \
47+
git \
48+
libjpeg-dev \
49+
libpng-dev \
50+
openssh-client \
51+
pngquant \
52+
tini \
53+
zlib1g-dev \
54+
libffi-dev \
55+
bash \
56+
&& rm -rf /var/lib/apt/lists/*
4857

49-
# Copy virtual env from python-deps stage
58+
# Copy virtual environment and local mkdocs-material module from python-deps stage
5059
COPY --from=python-deps /.venv /.venv
5160
COPY --from=python-deps /modules/mkdocs-material /modules/mkdocs-material
52-
ENV PATH="/.venv/bin:$PATH"
5361

54-
# Create and switch to a new user
55-
RUN mkdir /site
56-
WORKDIR /site
57-
58-
COPY docs docs
59-
COPY theme theme
60-
COPY includes includes
61-
COPY *.yml .
62-
COPY .cache/plugin/social/fonts .cache/plugin/social/fonts
63-
COPY run.sh .
64-
65-
EXPOSE 8000
66-
67-
ENV MKDOCS_INHERIT mkdocs-production.yml
62+
# Ensure the virtual environment’s bin directory is first in PATH
63+
ENV PATH="/.venv/bin:$PATH"
6864

6965
HEALTHCHECK NONE
7066

71-
ENTRYPOINT ["./run.sh"]
72-
CMD ["--cmd=mkdocs", "--insiders", "--cmd_flags=--dev-addr=0.0.0.0:8000"]
67+
# Entry point script and default cmd for running mkdocs
68+
ENTRYPOINT ["/bin/bash"]

0 commit comments

Comments
 (0)