add docker and deployment files

This commit is contained in:
2026-04-09 19:05:29 +02:00
parent 639b75578e
commit 7c00202929
5 changed files with 76 additions and 0 deletions

8
.dockerignore Normal file
View File

@@ -0,0 +1,8 @@
.git
.env
.env.*
!.env.example
terminal-shop-source/
*.db
data/
docs/

3
Caddyfile Normal file
View File

@@ -0,0 +1,3 @@
api.yourdomain.com {
reverse_proxy api:8080
}

13
Dockerfile.api Normal file
View File

@@ -0,0 +1,13 @@
FROM golang:alpine AS builder
WORKDIR /app
RUN apk add --no-cache gcc musl-dev
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=1 GOOS=linux go build -o api ./api/main.go
FROM alpine:3.21
RUN apk add --no-cache libc6-compat
WORKDIR /root/
COPY --from=builder /app/api .
CMD ["./api"]

11
Dockerfile.ssh Normal file
View File

@@ -0,0 +1,11 @@
FROM golang:alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o ssh ./main.go
FROM alpine:3.21
WORKDIR /root/
COPY --from=builder /app/ssh .
CMD TERM=xterm-256color ./ssh

41
docker-compose.prod.yml Normal file
View File

@@ -0,0 +1,41 @@
services:
api:
build:
context: .
dockerfile: Dockerfile.api
restart: unless-stopped
env_file: .env.prod
volumes:
- ./data:/data
expose:
- "8080"
ssh:
build:
context: .
dockerfile: Dockerfile.ssh
restart: unless-stopped
env_file: .env.prod
ports:
- "22:22"
volumes:
- ./.ssh:/root/.ssh
depends_on:
- api
caddy:
image: caddy:2-alpine
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- caddy_data:/data
- caddy_config:/config
depends_on:
- api
volumes:
caddy_data:
caddy_config: