Skip to content

Commit 5579a19

Browse files
Added template files (#43)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent c28f982 commit 5579a19

File tree

111 files changed

+23979
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+23979
-2
lines changed

β€Ž.copier-answers.yamlβ€Ž

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
2+
_commit: 04da514
3+
_src_path: ./
4+
accountname: quickplates
5+
description: Litestar service example 🌠
6+
docs: true
7+
docsurl: https://quickplates.github.io/litestar-example
8+
9+
envprefix: LITESTAR_EXAMPLE
10+
events: true
11+
imagename: services/litestar-example
12+
importname: litestar_example
13+
port: 8080
14+
registry: true
15+
releases: true
16+
reponame: litestar-example
17+
repourl: https://github.com/quickplates/litestar-example
18+
servicename: litestar-example
19+
sse: true
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
{
2+
// Build the base image
3+
"build": {
4+
// Docker context to use, relative to this file
5+
"context": "image/",
6+
// Dockerfile to use, relative to this file
7+
"dockerfile": "image/Dockerfile",
8+
// Build options
9+
"options": [
10+
// Use host network
11+
"--network=host"
12+
]
13+
},
14+
// Tool-specific settings
15+
"customizations": {
16+
// VS Code settings
17+
"vscode": {
18+
// Extensions to install
19+
"extensions": [
20+
// Nix
21+
"jnoortheen.nix-ide",
22+
// Direnv
23+
"mkhl.direnv",
24+
// Python
25+
"ms-python.python",
26+
// TOML
27+
"tamasfe.even-better-toml",
28+
// Task
29+
"task.vscode-task",
30+
// Trunk
31+
"Trunk.io"
32+
],
33+
// Settings to override
34+
"settings": {
35+
// Set Trunk as the default formatter
36+
"editor.defaultFormatter": "trunk.io",
37+
// Use LSP for Nix
38+
"nix.enableLanguageServer": true,
39+
// Use nil as the language server
40+
"nix.serverPath": "nil",
41+
"nix.serverSettings": {
42+
"nil": {
43+
"formatting": {
44+
// Use 'nix fmt' for formatting
45+
"command": ["nix", "fmt", "--", "-"]
46+
}
47+
}
48+
},
49+
// Don't forward ports automatically
50+
"remote.autoForwardPorts": false,
51+
// Use Nix IDE instead of Trunk for Nix files
52+
"[nix]": {
53+
"editor.defaultFormatter": "jnoortheen.nix-ide"
54+
}
55+
}
56+
}
57+
},
58+
// Extra features to install to the container
59+
"features": {
60+
// Install Nix
61+
"ghcr.io/devcontainers/features/nix:1.2.0": {
62+
// Enable experimental features
63+
"extraNixConfig": "experimental-features = nix-command flakes",
64+
"version": "2.26.2"
65+
},
66+
// Install Direnv
67+
"ghcr.io/devcontainers-extra/features/direnv:1.0.2": {
68+
"version": "2.35.0"
69+
},
70+
// Enable using Docker from within the container
71+
"ghcr.io/devcontainers/features/docker-in-docker:2.12.0": {
72+
"version": "27.5.1"
73+
},
74+
// Install Starship
75+
"ghcr.io/devcontainers-extra/features/starship:1.0.9": {
76+
"version": "1.22.1"
77+
}
78+
},
79+
// Volumes
80+
"mounts": [
81+
// Mount secrets (shared)
82+
"source=devcontainer-shared-secrets,target=/secrets/,type=volume",
83+
// Mount nix store (not shared)
84+
"source=devcontainer-${devcontainerId}-nix,target=/nix/,type=volume",
85+
// Mount shell history (not shared)
86+
"source=devcontainer-${devcontainerId}-shellhistory-persist,target=/persist/shellhistory/,type=volume",
87+
// Mount trunk cache (shared)
88+
"source=devcontainer-shared-trunk-cache,target=/cache/trunk/,type=volume",
89+
// Mount poetry cache (shared)
90+
"source=devcontainer-shared-poetry-cache,target=/cache/poetry/,type=volume",
91+
// Mount npm cache (shared)
92+
"source=devcontainer-shared-npm-cache,target=/cache/npm/,type=volume"
93+
],
94+
// Run a command when the container is created
95+
"onCreateCommand": "/hooks/create.sh",
96+
// Environment variables
97+
"remoteEnv": {
98+
// Set workspace path
99+
"WORKSPACE": "${containerWorkspaceFolder}"
100+
},
101+
// Run arguments
102+
"runArgs": [
103+
// Use host UTS namespace
104+
"--uts=host",
105+
// Use host IPC
106+
"--ipc=host",
107+
// Use host network
108+
"--network=host",
109+
// Use host user namespace
110+
"--userns=host",
111+
// Use host cgroup namespace
112+
"--cgroupns=host",
113+
// Run with elevated privileges
114+
"--privileged"
115+
]
116+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Using one of the offical dev container images as base
2+
# Going with Ubuntu, because it has glibc, which some tools might need
3+
# It also has git, zsh and a bunch of other stuff preinstalled
4+
# Also, it includes a non-root 'vscode' user with sudo access
5+
# The version is pinned to ensure reproducibility
6+
FROM mcr.microsoft.com/devcontainers/base:1.2.3-ubuntu-24.04
7+
8+
ENV REMOTE_USER=vscode
9+
10+
# Setup script
11+
COPY setup.sh /tmp/setup.sh
12+
13+
RUN /tmp/setup.sh && \
14+
rm /tmp/setup.sh
15+
16+
# Lifecycle hooks
17+
COPY hooks/ /hooks/
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
# Create shell history cache files if they don't exist for some reason
4+
touch /persist/shellhistory/.bash_history
5+
touch /persist/shellhistory/.zsh_history
6+
7+
# Use GitHub token secret if it exists
8+
if [[ -s /secrets/.ghtoken && -r /secrets/.ghtoken ]]; then
9+
token="$(cat /secrets/.ghtoken)"
10+
confighome="${XDG_CONFIG_HOME:-${HOME}/.config/}"
11+
12+
# Add GitHub token to Nix config
13+
configfile="${confighome}/nix/nix.conf"
14+
tmpfile="$(mktemp)"
15+
16+
mkdir --parents "$(dirname "${configfile}")"
17+
touch "${configfile}"
18+
19+
if grep --quiet extra-access-tokens "${configfile}"; then
20+
sed "s|extra-access-tokens.*|extra-access-tokens = github.com=${token}|" "${configfile}" >"${tmpfile}"
21+
cat "${tmpfile}" >"${configfile}"
22+
rm "${tmpfile}"
23+
else
24+
echo "extra-access-tokens = github.com=${token}" >>"${configfile}"
25+
fi
26+
fi

β€Ž.devcontainer/image/setup.shβ€Ž

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/usr/bin/env bash
2+
3+
REMOTE_USER="${REMOTE_USER:?}"
4+
REMOTE_USER_PASSWD="$(getent passwd "${REMOTE_USER}")"
5+
REMOTE_USER_HOME="$(echo "${REMOTE_USER_PASSWD}" | cut --delimiter ':' --fields 6)"
6+
7+
# Setup default shell
8+
chsh --shell /usr/bin/zsh "${REMOTE_USER}"
9+
10+
# Setup direnv
11+
cat <<EOF >>"${REMOTE_USER_HOME}/.bashrc"
12+
eval "\$(direnv hook bash)"
13+
EOF
14+
15+
cat <<EOF >>"${REMOTE_USER_HOME}/.zshrc"
16+
eval "\$(direnv hook zsh)"
17+
EOF
18+
19+
# Setup starship
20+
cat <<EOF >>"${REMOTE_USER_HOME}/.bashrc"
21+
eval "\$(starship init bash)"
22+
EOF
23+
24+
cat <<EOF >>"${REMOTE_USER_HOME}/.zshrc"
25+
eval "\$(starship init zsh)"
26+
EOF
27+
28+
# Setup secrets directory
29+
mkdir --parents /secrets/
30+
31+
chown --recursive "${REMOTE_USER}:" /secrets/
32+
33+
# Setup shell history cache
34+
mkdir --parents /persist/shellhistory/
35+
36+
touch /persist/shellhistory/.bash_history
37+
touch /persist/shellhistory/.zsh_history
38+
39+
chown --recursive "${REMOTE_USER}:" /persist/shellhistory/
40+
41+
cat <<EOF >>"${REMOTE_USER_HOME}/.bashrc"
42+
export HISTFILE=/persist/shellhistory/.bash_history
43+
EOF
44+
45+
cat <<EOF >>"${REMOTE_USER_HOME}/.zshrc"
46+
export HISTFILE=/persist/shellhistory/.zsh_history
47+
EOF
48+
49+
# Setup trunk cache
50+
mkdir --parents /cache/trunk/
51+
52+
chown --recursive "${REMOTE_USER}:" /cache/trunk/
53+
54+
cat <<EOF >>"${REMOTE_USER_HOME}/.bashrc"
55+
export TRUNK_CACHE=/cache/trunk/
56+
EOF
57+
58+
cat <<EOF >>"${REMOTE_USER_HOME}/.zshrc"
59+
export TRUNK_CACHE=/cache/trunk/
60+
EOF
61+
62+
# Setup poetry cache
63+
mkdir --parents /cache/poetry/
64+
65+
chown --recursive "${REMOTE_USER}:" /cache/poetry/
66+
67+
cat <<EOF >>"${REMOTE_USER_HOME}/.bashrc"
68+
export POETRY_CACHE_DIR=/cache/poetry/
69+
EOF
70+
71+
cat <<EOF >>"${REMOTE_USER_HOME}/.zshrc"
72+
export POETRY_CACHE_DIR=/cache/poetry/
73+
EOF
74+
75+
# Setup npm cache
76+
mkdir --parents /cache/npm/
77+
78+
chown --recursive "${REMOTE_USER}:" /cache/npm/
79+
80+
cat <<EOF >>"${REMOTE_USER_HOME}/.bashrc"
81+
export NPM_CONFIG_CACHE=/cache/npm/
82+
EOF
83+
84+
cat <<EOF >>"${REMOTE_USER_HOME}/.zshrc"
85+
export NPM_CONFIG_CACHE=/cache/npm/
86+
EOF

β€Ž.dockerignoreβ€Ž

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#Task
2+
/.task/
3+
/Taskfile.yaml
4+
/Taskfile.yml
5+
6+
# Misc
7+
.DS_Store
8+
.todo
9+
10+
# Byte-compiled / optimized / DLL files
11+
__pycache__/
12+
*.py[cod]
13+
*$py.class
14+
15+
# C extensions
16+
*.so
17+
18+
# Pytest
19+
.pytest_cache/
20+
21+
# Environment
22+
/.venv/
23+
24+
# Tracked, but not needed
25+
/.devcontainer/
26+
/.github/
27+
/.trunk/
28+
/.vscode/
29+
/docs/
30+
/tests/
31+
/.copier-answers.yaml
32+
/.dockerignore
33+
/.envrc
34+
/.gitattributes
35+
/.gitignore
36+
/CONTRIBUTING.md
37+
/docker-compose.yaml
38+
/Dockerfile
39+
/LICENSE
40+
/README.md
41+
/Taskfile.dist.yaml

β€Ž.env.pythonβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Include Python packages installed by Nix
2+
PYTHONPATH=${EXTRAPYTHONPATH}

β€Ž.envrcβ€Ž

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
# reload when these files change
4+
watch_file flake.lock ./*.nix
5+
6+
# activate the default development shell in the current shell
7+
# --accept-flake-config will accept the nix configuration from the flake without prompting
8+
eval "$(nix print-dev-env path:./ --accept-flake-config)" || true

β€Ž.gitattributesβ€Ž

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Mark everything as vendored
2+
* linguist-vendored
3+
# Treat docs as documentation
4+
/docs/** -linguist-vendored linguist-documentation
5+
# Unmark files in src, so that they are included in language stats
6+
/src/** -linguist-vendored
7+
# Treat tests as documentation
8+
/tests/** -linguist-vendored linguist-documentation

β€Ž.github/release.yamlβ€Ž

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
changelog:
2+
exclude:
3+
# Exclude PRs with the following labels from the changelog
4+
labels:
5+
- skip-changelog
6+
# Categories are used make sections in the changelog based on PR labels
7+
categories:
8+
- title: πŸš€ Features
9+
labels:
10+
- feature
11+
- title: πŸ› Bug Fixes
12+
labels:
13+
- bug
14+
- title: 🧽 Cleanup
15+
labels:
16+
- cleanup

0 commit comments

Comments
Β (0)