Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .copier-answers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: 6e5275f
_src_path: ./
accountname: quickplates
description: Litestar service example 🌠
docs: true
docsurl: https://quickplates.github.io/litestar-example
envprefix: LITESTAR_EXAMPLE
imagename: services/litestar-example
importname: litestar_example
port: 8080
registry: true
releases: true
reponame: litestar-example
repourl: https://github.com/quickplates/litestar-example
servicename: litestar-example
71 changes: 71 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"build": {
"context": "image/",
"dockerfile": "image/Dockerfile",
"options": ["--network=host"]
},
"customizations": {
"vscode": {
"extensions": [
"jnoortheen.nix-ide",
"mkhl.direnv",
"ms-python.python",
"tamasfe.even-better-toml",
"task.vscode-task",
"Trunk.io"
],
"settings": {
"[nix]": {
"editor.defaultFormatter": "jnoortheen.nix-ide"
},
"editor.defaultFormatter": "trunk.io",
"nix.enableLanguageServer": true,
"nix.serverPath": "nil",
"nix.serverSettings": {
"nil": {
"formatting": {
"command": ["nix", "fmt", "--", "-"]
}
}
},
"python.analysis.nodeExecutable": "auto",
"remote.autoForwardPorts": false
}
}
},
"features": {
"ghcr.io/devcontainers-extra/features/direnv:1.0.3": {
"version": "2.37.1"
},
"ghcr.io/devcontainers-extra/features/starship:1.0.10": {
"version": "1.24.0"
},
"ghcr.io/devcontainers/features/docker-in-docker:2.12.4": {
"version": "28.5.1"
},
"ghcr.io/devcontainers/features/nix:1.2.0": {
"extraNixConfig": "experimental-features = nix-command flakes",
"version": "2.28.5"
}
},
"mounts": [
"source=devcontainer-shared-secrets,target=/secrets/,type=volume",
"source=devcontainer-${devcontainerId}-nix,target=/nix/,type=volume",
"source=devcontainer-${devcontainerId}-shellhistory-persist,target=/persist/shellhistory/,type=volume",
"source=devcontainer-shared-trunk-cache,target=/cache/trunk/,type=volume",
"source=devcontainer-shared-uv-cache,target=/cache/uv/,type=volume",
"source=devcontainer-shared-npm-cache,target=/cache/npm/,type=volume"
],
"onCreateCommand": "/hooks/create.sh",
"remoteEnv": {
"WORKSPACE": "${containerWorkspaceFolder}"
},
"runArgs": [
"--uts=host",
"--ipc=host",
"--network=host",
"--userns=host",
"--cgroupns=host",
"--privileged"
]
}
17 changes: 17 additions & 0 deletions .devcontainer/image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Using one of the offical dev container images as base
# Going with Ubuntu, because it has glibc, which some tools might need
# It also has git, zsh and a bunch of other stuff preinstalled
# Also, it includes a non-root 'vscode' user with sudo access
# The version is pinned to ensure reproducibility
FROM mcr.microsoft.com/devcontainers/base:1.2.6-ubuntu-24.04

ENV REMOTE_USER=vscode

# Setup script
COPY setup.sh /tmp/setup.sh

RUN /tmp/setup.sh && \
rm /tmp/setup.sh

# Lifecycle hooks
COPY hooks/ /hooks/
26 changes: 26 additions & 0 deletions .devcontainer/image/hooks/create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

# Create shell history cache files if they don't exist for some reason
touch /persist/shellhistory/.bash_history
touch /persist/shellhistory/.zsh_history

# Use GitHub token secret if it exists
if [[ -s /secrets/.ghtoken && -r /secrets/.ghtoken ]]; then
token="$(cat /secrets/.ghtoken)"
confighome="${XDG_CONFIG_HOME:-${HOME}/.config/}"

# Add GitHub token to Nix config
configfile="${confighome}/nix/nix.conf"
tmpfile="$(mktemp)"

mkdir --parents "$(dirname "${configfile}")"
touch "${configfile}"

if grep --quiet extra-access-tokens "${configfile}"; then
sed "s|extra-access-tokens.*|extra-access-tokens = github.com=${token}|" "${configfile}" >"${tmpfile}"
cat "${tmpfile}" >"${configfile}"
rm "${tmpfile}"
else
echo "extra-access-tokens = github.com=${token}" >>"${configfile}"
fi
fi
88 changes: 88 additions & 0 deletions .devcontainer/image/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/usr/bin/env bash

REMOTE_USER="${REMOTE_USER:?}"
REMOTE_USER_PASSWD="$(getent passwd "${REMOTE_USER}")"
REMOTE_USER_HOME="$(echo "${REMOTE_USER_PASSWD}" | cut --delimiter ':' --fields 6)"

# Setup default shell
chsh --shell /usr/bin/zsh "${REMOTE_USER}"

# Setup direnv
cat <<EOF >>"${REMOTE_USER_HOME}/.bashrc"
eval "\$(direnv hook bash)"
EOF

cat <<EOF >>"${REMOTE_USER_HOME}/.zshrc"
eval "\$(direnv hook zsh)"
EOF

# Setup starship
cat <<EOF >>"${REMOTE_USER_HOME}/.bashrc"
eval "\$(starship init bash)"
EOF

cat <<EOF >>"${REMOTE_USER_HOME}/.zshrc"
eval "\$(starship init zsh)"
EOF

# Setup secrets directory
mkdir --parents /secrets/

chown --recursive "${REMOTE_USER}:" /secrets/

# Setup shell history cache
mkdir --parents /persist/shellhistory/

touch /persist/shellhistory/.bash_history
touch /persist/shellhistory/.zsh_history

chown --recursive "${REMOTE_USER}:" /persist/shellhistory/

cat <<EOF >>"${REMOTE_USER_HOME}/.bashrc"
export HISTFILE=/persist/shellhistory/.bash_history
EOF

cat <<EOF >>"${REMOTE_USER_HOME}/.zshrc"
export HISTFILE=/persist/shellhistory/.zsh_history
EOF

# Setup trunk cache
mkdir --parents /cache/trunk/

chown --recursive "${REMOTE_USER}:" /cache/trunk/

cat <<EOF >>"${REMOTE_USER_HOME}/.bashrc"
export TRUNK_CACHE=/cache/trunk/
EOF

cat <<EOF >>"${REMOTE_USER_HOME}/.zshrc"
export TRUNK_CACHE=/cache/trunk/
EOF

# Setup uv cache
mkdir --parents /cache/uv/

chown --recursive "${REMOTE_USER}:" /cache/uv/

cat <<EOF >>"${REMOTE_USER_HOME}/.bashrc"
export UV_CACHE_DIR=/cache/uv/
export UV_LINK_MODE=copy
EOF

cat <<EOF >>"${REMOTE_USER_HOME}/.zshrc"
export UV_CACHE_DIR=/cache/uv/
export UV_LINK_MODE=copy
EOF

# Setup npm cache
mkdir --parents /cache/npm/

chown --recursive "${REMOTE_USER}:" /cache/npm/

cat <<EOF >>"${REMOTE_USER_HOME}/.bashrc"
export NPM_CONFIG_CACHE=/cache/npm/
EOF

cat <<EOF >>"${REMOTE_USER_HOME}/.zshrc"
export NPM_CONFIG_CACHE=/cache/npm/
EOF
41 changes: 41 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#Task
/.task/
/Taskfile.yaml
/Taskfile.yml

# Misc
.DS_Store
.todo

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Pytest
.pytest_cache/

# Environment
/.venv/

# Tracked, but not needed
/.devcontainer/
/.github/
/.trunk/
/.vscode/
/docs/
/tests/
/.copier-answers.yaml
/.dockerignore
/.envrc
/.gitattributes
/.gitignore
/CONTRIBUTING.md
/docker-compose.yaml
/Dockerfile
/LICENSE
/README.md
/Taskfile.dist.yaml
8 changes: 8 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

# reload when these files change
watch_file flake.lock ./*.nix

# activate the default development shell in the current shell
# --accept-flake-config will accept the nix configuration from the flake without prompting
eval "$(nix print-dev-env path:./ --accept-flake-config)" || true
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Mark everything as vendored
* linguist-vendored
# Treat docs as documentation
/docs/** -linguist-vendored linguist-documentation
# Unmark files in src, so that they are included in language stats
/src/** -linguist-vendored
# Treat tests as documentation
/tests/** -linguist-vendored linguist-documentation
16 changes: 16 additions & 0 deletions .github/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
changelog:
exclude:
# Exclude PRs with the following labels from the changelog
labels:
- skip-changelog
# Categories are used make sections in the changelog based on PR labels
categories:
- title: 🚀 Features
labels:
- feature
- title: 🐛 Bug Fixes
labels:
- bug
- title: 🧽 Cleanup
labels:
- cleanup
Loading