Use dind for maximum nonsense

This commit is contained in:
Gender Shrapnel 2025-01-23 05:15:57 +00:00
parent bb0975a2d8
commit 5277cf0cc5
Signed by: modzero
SSH Key Fingerprint: SHA256:hsF2onMcqHsX09jLIFn7GvltdH9NTfFd/1tCnBNfQ4g
6 changed files with 52 additions and 9 deletions

View File

@ -4,8 +4,27 @@
"dockerfile": "../dockerfiles/devcontainer.dockerfile", "dockerfile": "../dockerfiles/devcontainer.dockerfile",
"context": ".." "context": ".."
}, },
"forwardPorts": [
80, 443, 2019
],
"portsAttributes": {
"80": {
"label": "Plaintext",
"protocol": "http",
"elevateIfNeeded": true
},
"443": {
"label": "Encrypted",
"protocol": "https",
"elevateIfNeeded": true
},
"2019": {
"label": "Admin API",
"protocol": "http",
}
},
"features": { "features": {
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": { "ghcr.io/devcontainers/features/docker-in-docker:2": {
"installDockerComposeSwitch": false "installDockerComposeSwitch": false
}, },
"ghcr.io/devcontainers/features/node:1": { "ghcr.io/devcontainers/features/node:1": {
@ -23,9 +42,8 @@
"onCreateCommand": "${containerWorkspaceFolder}/.devcontainer/onCreate.sh", "onCreateCommand": "${containerWorkspaceFolder}/.devcontainer/onCreate.sh",
"postAttachCommand": "${containerWorkspaceFolder}/.devcontainer/postAttach.sh", "postAttachCommand": "${containerWorkspaceFolder}/.devcontainer/postAttach.sh",
"remoteEnv": { "remoteEnv": {
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}",
"WORKSPACE_FOLDER": "${containerWorkspaceFolder}", "WORKSPACE_FOLDER": "${containerWorkspaceFolder}",
"UV_LINK_MODE": "copy", "UV_LINK_MODE": "copy"
}, },
"mounts": [ "mounts": [
{ {
@ -37,7 +55,13 @@
"type": "volume", "type": "volume",
"source": "${devcontainerId}-node-modules", "source": "${devcontainerId}-node-modules",
"target": "${containerWorkspaceFolder}/node_modules" "target": "${containerWorkspaceFolder}/node_modules"
},
{
"type": "volume",
"source": "${devcontainerId}-bashhistory",
"target": "/commandhistory"
} }
], ],
"customizations": { "customizations": {
"vscode": { "vscode": {

View File

@ -13,7 +13,8 @@ git config --global --add safe.directory ${WORKSPACE_FOLDER}
sudo chown $(id -u):$(id -g) -fR \ sudo chown $(id -u):$(id -g) -fR \
${WORKSPACE_FOLDER} \ ${WORKSPACE_FOLDER} \
${WORKSPACE_FOLDER}/.venv \ ${WORKSPACE_FOLDER}/.venv \
${WORKSPACE_FOLDER}/node_modules ${WORKSPACE_FOLDER}/node_modules \
/commandhistory
cd ${WORKSPACE_FOLDER} cd ${WORKSPACE_FOLDER}

View File

@ -7,14 +7,14 @@ services:
pull_policy: build pull_policy: build
develop: develop:
watch: watch:
- path: ${LOCAL_WORKSPACE_FOLDER:-.}/kredens - path: ./kredens
action: sync action: sync
target: /app/kredens target: /app/kredens
- path: ${LOCAL_WORKSPACE_FOLDER:-.}/pyproject.toml - path: ./pyproject.toml
action: rebuild action: rebuild
- path: ${LOCAL_WORKSPACE_FOLDER:-.}/manage.py - path: ./manage.py
action: rebuild action: rebuild
- path: ${LOCAL_WORKSPACE_FOLDER:-.}/uv.lock - path: ./uv.lock
action: rebuild action: rebuild
environment: environment:
- DATABASE_URL=postgres://postgres:${DATABASE_PASSWORD:?Database password required}@database/kredens - DATABASE_URL=postgres://postgres:${DATABASE_PASSWORD:?Database password required}@database/kredens
@ -43,7 +43,7 @@ services:
cap_add: cap_add:
- NET_ADMIN - NET_ADMIN
volumes: volumes:
- ${LOCAL_WORKSPACE_FOLDER:-.}/configs/caddy/:/etc/caddy/ - ./configs/caddy/:/etc/caddy/
- caddy_data:/data - caddy_data:/data
- caddy_config:/config - caddy_config:/config
ports: ports:

View File

@ -1,5 +1,7 @@
FROM mcr.microsoft.com/devcontainers/base:bookworm FROM mcr.microsoft.com/devcontainers/base:bookworm
ARG USERNAME=vscode
# Install things I need for Caddy and such # Install things I need for Caddy and such
RUN \ RUN \
@ -27,3 +29,11 @@ RUN \
RUN mkdir -p /workspaces/kredens && chown vscode:vscode /workspaces RUN mkdir -p /workspaces/kredens && chown vscode:vscode /workspaces
WORKDIR /workspaces/kredens WORKDIR /workspaces/kredens
# Persist history
RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.bash_history" \
&& mkdir /commandhistory \
&& touch /commandhistory/.bash_history \
&& chown -R $USERNAME /commandhistory \
&& echo "$SNIPPET" >> "/home/$USERNAME/.bashrc"

View File

@ -1,2 +1,8 @@
watch: watch:
docker compose up --watch docker compose up --watch
migrate:
uv run ./manage.py migrate
bootstrap:
uv run ./manage.py bootstrap

View File

@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/5.1/ref/settings/
""" """
from pathlib import Path from pathlib import Path
import os
import dj_database_url import dj_database_url
@ -82,6 +83,7 @@ WSGI_APPLICATION = "kredens.wsgi.application"
DATABASES = { DATABASES = {
"default": dj_database_url.config( "default": dj_database_url.config(
default=f"postgres://postgres:{os.environ.get("DATABASE_PASSWORD")}@localhost/kredens",
conn_max_age=600, conn_max_age=600,
conn_health_checks=True, conn_health_checks=True,
), ),