feat: implement license platform business flows and delivery tooling
Add admin and customer interfaces, orders, signed activation and leases, protected package delivery, keyring verification, migrations, security controls, tests and deployment documentation. Co-Authored-By: Craft Agent <agents-noreply@craft.do>
This commit is contained in:
17
deploy/Dockerfile.api
Normal file
17
deploy/Dockerfile.api
Normal file
@@ -0,0 +1,17 @@
|
||||
FROM golang:1.23-alpine AS build
|
||||
WORKDIR /src
|
||||
COPY backend/go.mod backend/go.sum ./
|
||||
RUN go mod download
|
||||
COPY backend/ ./
|
||||
RUN CGO_ENABLED=0 go build -o /out/server ./cmd/server && CGO_ENABLED=0 go build -o /out/migrate ./cmd/migrate
|
||||
|
||||
FROM alpine:3.21
|
||||
RUN apk add --no-cache ca-certificates wget && addgroup -g 10001 app && adduser -D -u 10001 -G app app
|
||||
WORKDIR /app
|
||||
COPY --from=build /out/ /app/
|
||||
COPY backend/migrations /app/migrations
|
||||
COPY deploy/entrypoint.sh /app/entrypoint.sh
|
||||
RUN chmod 0555 /app/entrypoint.sh
|
||||
USER 10001:10001
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||
CMD ["/app/server"]
|
||||
9
deploy/Dockerfile.web
Normal file
9
deploy/Dockerfile.web
Normal file
@@ -0,0 +1,9 @@
|
||||
FROM node:22-alpine AS build
|
||||
WORKDIR /src
|
||||
COPY frontend/package.json frontend/package-lock.json ./
|
||||
RUN npm ci
|
||||
COPY frontend/ ./
|
||||
RUN npm run build
|
||||
FROM nginx:stable-alpine
|
||||
COPY --from=build /src/dist /usr/share/nginx/html
|
||||
COPY deploy/nginx/compose.conf /etc/nginx/conf.d/default.conf
|
||||
10
deploy/entrypoint.sh
Normal file
10
deploy/entrypoint.sh
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
if [ -n "${MYSQL_PASSWORD_FILE:-}" ]; then
|
||||
password=$(cat "$MYSQL_PASSWORD_FILE")
|
||||
case "$password" in ''|*[!a-zA-Z0-9_-]*) echo 'Database secret must be a nonempty URL-safe value' >&2; exit 1;; esac
|
||||
export MYSQL_DSN="license_app:${password}@tcp(mysql:3306)/license_platform?parseTime=true"
|
||||
export MIGRATION_DSN="mysql://license_app:${password}@tcp(mysql:3306)/license_platform?multiStatements=true"
|
||||
unset password
|
||||
fi
|
||||
exec "$@"
|
||||
22
deploy/nginx/compose.conf
Normal file
22
deploy/nginx/compose.conf
Normal file
@@ -0,0 +1,22 @@
|
||||
server {
|
||||
listen 8080;
|
||||
server_name localhost;
|
||||
client_max_body_size 64m;
|
||||
root /usr/share/nginx/html;
|
||||
location /api/ {
|
||||
proxy_pass http://api:18080;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_read_timeout 60s;
|
||||
}
|
||||
location /_packages/ {
|
||||
internal;
|
||||
alias /srv/license-packages/;
|
||||
autoindex off;
|
||||
disable_symlinks on;
|
||||
add_header Cache-Control "private, no-store" always;
|
||||
add_header X-Package-SHA256 $upstream_http_x_package_sha256 always;
|
||||
}
|
||||
location / { try_files $uri $uri/ /index.html; }
|
||||
}
|
||||
18
deploy/nginx/download-local.conf
Normal file
18
deploy/nginx/download-local.conf
Normal file
@@ -0,0 +1,18 @@
|
||||
# Isolated development reverse-proxy fragment. Mount PACKAGE_STORAGE_ROOT read-only at /srv/license-packages.
|
||||
# The upstream application must set X-Accel-Redirect only after authorization and audit commit.
|
||||
server {
|
||||
listen 18181;
|
||||
server_name 127.0.0.1;
|
||||
location = /_packages { return 404; }
|
||||
location /_packages/ {
|
||||
internal;
|
||||
alias /srv/license-packages/;
|
||||
autoindex off;
|
||||
disable_symlinks on;
|
||||
add_header Cache-Control "private, no-store" always;
|
||||
add_header X-Package-SHA256 $upstream_http_x_package_sha256 always;
|
||||
limit_except GET HEAD { deny all; }
|
||||
}
|
||||
client_max_body_size 64m;
|
||||
location / { proxy_pass http://host.docker.internal:18082; }
|
||||
}
|
||||
30
deploy/nginx/tls-proxy.conf.example
Normal file
30
deploy/nginx/tls-proxy.conf.example
Normal file
@@ -0,0 +1,30 @@
|
||||
# Example only. Use certificates issued/managed by your production certificate authority.
|
||||
# Do not copy a self-signed development certificate into this profile.
|
||||
# Mount this as a server block and bind /run/tls read-only from the managed certificate path.
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name license.example.invalid;
|
||||
ssl_certificate /run/tls/fullchain.pem;
|
||||
ssl_certificate_key /run/tls/privatekey.pem;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
client_max_body_size 64m;
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://api:18080;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_read_timeout 60s;
|
||||
}
|
||||
location /_packages/ {
|
||||
internal;
|
||||
alias /srv/license-packages/;
|
||||
autoindex off;
|
||||
disable_symlinks on;
|
||||
add_header Cache-Control "private, no-store" always;
|
||||
add_header X-Package-SHA256 $upstream_http_x_package_sha256 always;
|
||||
}
|
||||
location / { root /usr/share/nginx/html; try_files $uri $uri/ /index.html; }
|
||||
}
|
||||
# Restrict listener/network reachability to the actual proxy tier. Configure the API's
|
||||
# HTTP_TRUSTED_PROXY_CIDRS to exact proxy source CIDRs only when this proxy is in use.
|
||||
Reference in New Issue
Block a user