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
19 changes: 19 additions & 0 deletions .copier-answers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: 04da514
_src_path: ./
accountname: quickplates
description: Litestar service example 🌠
docs: true
docsurl: https://quickplates.github.io/litestar-example
email: [email protected]
envprefix: LITESTAR_EXAMPLE
events: true
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
sse: true
116 changes: 116 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
// Build the base image
"build": {
// Docker context to use, relative to this file
"context": "image/",
// Dockerfile to use, relative to this file
"dockerfile": "image/Dockerfile",
// Build options
"options": [
// Use host network
"--network=host"
]
},
// Tool-specific settings
"customizations": {
// VS Code settings
"vscode": {
// Extensions to install
"extensions": [
// Nix
"jnoortheen.nix-ide",
// Direnv
"mkhl.direnv",
// Python
"ms-python.python",
// TOML
"tamasfe.even-better-toml",
// Task
"task.vscode-task",
// Trunk
"Trunk.io"
],
// Settings to override
"settings": {
// Set Trunk as the default formatter
"editor.defaultFormatter": "trunk.io",
// Use LSP for Nix
"nix.enableLanguageServer": true,
// Use nil as the language server
"nix.serverPath": "nil",
"nix.serverSettings": {
"nil": {
"formatting": {
// Use 'nix fmt' for formatting
"command": ["nix", "fmt", "--", "-"]
}
}
},
// Don't forward ports automatically
"remote.autoForwardPorts": false,
// Use Nix IDE instead of Trunk for Nix files
"[nix]": {
"editor.defaultFormatter": "jnoortheen.nix-ide"
}
}
}
},
// Extra features to install to the container
"features": {
// Install Nix
"ghcr.io/devcontainers/features/nix:1.2.0": {
// Enable experimental features
"extraNixConfig": "experimental-features = nix-command flakes",
"version": "2.26.2"
},
// Install Direnv
"ghcr.io/devcontainers-extra/features/direnv:1.0.2": {
"version": "2.35.0"
},
// Enable using Docker from within the container
"ghcr.io/devcontainers/features/docker-in-docker:2.12.0": {
"version": "27.5.1"
},
// Install Starship
"ghcr.io/devcontainers-extra/features/starship:1.0.9": {
"version": "1.22.1"
}
},
// Volumes
"mounts": [
// Mount secrets (shared)
"source=devcontainer-shared-secrets,target=/secrets/,type=volume",
// Mount nix store (not shared)
"source=devcontainer-${devcontainerId}-nix,target=/nix/,type=volume",
// Mount shell history (not shared)
"source=devcontainer-${devcontainerId}-shellhistory-persist,target=/persist/shellhistory/,type=volume",
// Mount trunk cache (shared)
"source=devcontainer-shared-trunk-cache,target=/cache/trunk/,type=volume",
// Mount poetry cache (shared)
"source=devcontainer-shared-poetry-cache,target=/cache/poetry/,type=volume",
// Mount npm cache (shared)
"source=devcontainer-shared-npm-cache,target=/cache/npm/,type=volume"
],
// Run a command when the container is created
"onCreateCommand": "/hooks/create.sh",
// Environment variables
"remoteEnv": {
// Set workspace path
"WORKSPACE": "${containerWorkspaceFolder}"
},
// Run arguments
"runArgs": [
// Use host UTS namespace
"--uts=host",
// Use host IPC
"--ipc=host",
// Use host network
"--network=host",
// Use host user namespace
"--userns=host",
// Use host cgroup namespace
"--cgroupns=host",
// Run with elevated privileges
"--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.3-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
86 changes: 86 additions & 0 deletions .devcontainer/image/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/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 poetry cache
mkdir --parents /cache/poetry/

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

cat <<EOF >>"${REMOTE_USER_HOME}/.bashrc"
export POETRY_CACHE_DIR=/cache/poetry/
EOF

cat <<EOF >>"${REMOTE_USER_HOME}/.zshrc"
export POETRY_CACHE_DIR=/cache/poetry/
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
2 changes: 2 additions & 0 deletions .env.python
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Include Python packages installed by Nix
PYTHONPATH=${EXTRAPYTHONPATH}
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