Skip to content

Commit ee460ff

Browse files
committed
feat: basic devcontainer setup for local builds
run as a non-root user
1 parent acf10e7 commit ee460ff

File tree

9 files changed

+136
-1
lines changed

9 files changed

+136
-1
lines changed

.devcontainer/Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM python:3.11
2+
3+
ENV PYTHONDONTWRITEBYTECODE=1 \
4+
PYTHONUNBUFFERED=1 \
5+
USER=compiler
6+
7+
RUN apt-get update
8+
RUN apt-get install -y ruby-full && gem install bundler
9+
RUN python -m pip install --upgrade pip
10+
11+
RUN useradd --create-home --shell /bin/bash $USER && \
12+
chown -R $USER /home/$USER
13+
14+
WORKDIR /home/$USER/site
15+
16+
COPY Gemfile Gemfile
17+
COPY Gemfile.lock Gemfile.lock
18+
RUN bundle install
19+
20+
USER $USER
21+
ENV PATH "$PATH:/home/$USER/.local/bin"
22+
23+
COPY .devcontainer/requirements.txt .devcontainer/requirements.txt
24+
RUN pip install --no-cache-dir -r .devcontainer/requirements.txt

.devcontainer/compose.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
services:
2+
site:
3+
build:
4+
context: ..
5+
dockerfile: .devcontainer/Dockerfile
6+
command: sleep infinity
7+
volumes:
8+
- ..:/home/compiler/site

.devcontainer/devcontainer.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "compiler/datadonuts.la",
3+
"dockerComposeFile": "compose.yml",
4+
"service": "site",
5+
"workspaceFolder": "/home/compiler/site",
6+
"postAttachCommand": ["/bin/bash", ".devcontainer/postAttach.sh"],
7+
"customizations": {
8+
"vscode": {
9+
"settings": {
10+
"terminal.integrated.defaultProfile.linux": "bash",
11+
"terminal.integrated.profiles.linux": {
12+
"bash": {
13+
"path": "/bin/bash"
14+
}
15+
}
16+
},
17+
"extensions": [
18+
"eamodio.gitlens",
19+
"esbenp.prettier-vscode",
20+
"mhutchie.git-graph",
21+
"redhat.vscode-xml",
22+
"sissel.shopify-liquid",
23+
"tamasfe.even-better-toml"
24+
]
25+
}
26+
}
27+
}

.devcontainer/postAttach.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
4+
git config --global --add safe.directory /home/compiler/site
5+
6+
# initialize hook environments
7+
pre-commit install --install-hooks --overwrite
8+
9+
# manage commit-msg hooks
10+
pre-commit install --hook-type commit-msg

.devcontainer/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pre-commit

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
.jekyll-metadata
33
.idea/
44
_site/
5-
.DS_Store
5+
.DS_Store

.pre-commit-config.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
ci:
2+
autofix_commit_msg: "chore(pre-commit): autofix run"
3+
autoupdate_commit_msg: "chore(pre-commit): autoupdate hooks"
4+
5+
default_install_hook_types:
6+
- pre-commit
7+
- commit-msg
8+
9+
repos:
10+
- repo: https://github.com/compilerla/conventional-pre-commit
11+
rev: v3.4.0
12+
hooks:
13+
- id: conventional-pre-commit
14+
stages: [commit-msg]
15+
16+
- repo: https://github.com/pre-commit/pre-commit-hooks
17+
rev: v4.6.0
18+
hooks:
19+
- id: trailing-whitespace
20+
- id: mixed-line-ending
21+
- id: end-of-file-fixer
22+
- id: requirements-txt-fixer
23+
- id: check-yaml
24+
args: ["--unsafe"]
25+
- id: check-added-large-files

.vscode/settings.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"editor.defaultFormatter": "esbenp.prettier-vscode",
4+
"files.encoding": "utf8",
5+
"files.eol": "\n",
6+
"files.insertFinalNewline": true,
7+
"files.trimFinalNewlines": true,
8+
"files.trimTrailingWhitespace": true,
9+
"editor.tabSize": 2,
10+
"files.associations": {
11+
"*.html": "liquid"
12+
},
13+
"[liquid]": {
14+
"editor.defaultFormatter": "sissel.shopify-liquid"
15+
}
16+
}

.vscode/tasks.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"label": "Jekyll: Build Dev",
8+
"type": "shell",
9+
"command": ["bundle", "exec", "jekyll serve --force_polling --livereload"],
10+
"group": {
11+
"kind": "build",
12+
"isDefault": true
13+
},
14+
"presentation": {
15+
"echo": true,
16+
"reveal": "always",
17+
"focus": false,
18+
"panel": "shared",
19+
"showReuseMessage": true,
20+
"clear": false
21+
}
22+
}
23+
]
24+
}

0 commit comments

Comments
 (0)