feat(docker): add split backend/frontend stacks and dynamic versioning

This commit is contained in:
Alphaeus Mote
2025-11-19 09:13:21 -05:00
parent be6d358086
commit f294047c87
19 changed files with 696 additions and 8 deletions
+18
View File
@@ -0,0 +1,18 @@
###BEGIN GENERAL###
STACK_NAME=stk-depl0y-frontend-001
STACK_BINDMOUNTROOT=custom/docker/stacks
TZ=America/New_York
UID=0
GID=0
SERVICE_BIND_ADDRESS_EXTERNAL=0.0.0.0
SERVICE_BIND_ADDRESS_INTERNAL=127.0.0.1
DNSSERVER=1.1.1.1
###END GENERAL###
###BEGIN FRONTEND###
FRONTEND_IMAGENAME=Agit8or/Depl0y-frontend
FRONTEND_IMAGEVERSION=latest
FRONTEND_ENABLEAUTOMATICUPDATES=true
FRONTEND_PORT_EXTERNAL=8080
###END FRONTEND###
+16
View File
@@ -0,0 +1,16 @@
FROM nginx:alpine
ARG APP_VERSION=1.1.9
ENV APP_VERSION=${APP_VERSION}
# Copy built frontend assets into nginx web root
COPY src/frontend/dist /usr/share/nginx/html
# Custom nginx config for SPA routing (serve index.html for unknown routes)
COPY deployment/docker/frontend/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
IMAGE_NAME="${IMAGE_NAME:-Agit8or/Depl0y-frontend}"
APP_VERSION="${APP_VERSION:-$(date +%Y.%m.%d.%H%M)}"
VERSION_TAG="${IMAGE_TAG:-${APP_VERSION}}"
echo "Building ${IMAGE_NAME}:${VERSION_TAG} and ${IMAGE_NAME}:latest from ${ROOT_DIR}..."
docker build \
-f "${ROOT_DIR}/deployment/docker/frontend/Dockerfile" \
--build-arg APP_VERSION="${VERSION_TAG}" \
-t "${IMAGE_NAME}:${VERSION_TAG}" \
-t "${IMAGE_NAME}:latest" \
"${ROOT_DIR}"
if [ "${PUSH:-false}" = "true" ]; then
echo "Pushing ${IMAGE_NAME}:${VERSION_TAG} and ${IMAGE_NAME}:latest..."
docker push "${IMAGE_NAME}:${VERSION_TAG}"
docker.push "${IMAGE_NAME}:latest"
fi
echo "Done."
@@ -0,0 +1,33 @@
name: '${STACK_NAME:-stk-depl0y-frontend-001}'
networks:
EXTERNAL:
name: DEPL0Y-FRONTEND-EXTERNAL
driver: bridge
internal: false
attachable: true
services:
Frontend:
image: '${FRONTEND_IMAGENAME:-Agit8or/Depl0y-frontend}:${FRONTEND_IMAGEVERSION:-latest}'
container_name: DEPL0Y-FRONTEND-001
hostname: DEPL0Y-FRONTEND-001
restart: unless-stopped
stop_signal: SIGTERM
stop_grace_period: 90s
user: '${UID:-0}:${GID:-0}'
logging:
driver: 'local'
#env_file: '.env'
networks:
EXTERNAL:
ports:
- "${SERVICE_BIND_ADDRESS_EXTERNAL:-0.0.0.0}:${FRONTEND_PORT_EXTERNAL:-8080}:80"
dns:
- '${DNSSERVER:-127.0.0.53}'
volumes:
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
labels:
com.centurylinklabs.watchtower.enable: ${FRONTEND_ENABLEAUTOMATICUPDATES:-true}
+12
View File
@@ -0,0 +1,12 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri /index.html;
}
}