Compare commits
2 Commits
dc2ce1f349
...
3f8a4024ce
Author | SHA1 | Date | |
---|---|---|---|
3f8a4024ce | |||
e8a74999c3 |
53
Dockerfile
Normal file
53
Dockerfile
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
# Stage 1: Build frontend
|
||||||
|
FROM node:22 AS frontend-builder
|
||||||
|
WORKDIR /app/web
|
||||||
|
COPY web/ .
|
||||||
|
RUN npm install && npm run build
|
||||||
|
|
||||||
|
# Stage 2: Build backend
|
||||||
|
FROM golang:1.24 AS backend-builder
|
||||||
|
WORKDIR /app
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
# Copy built frontend into Go embed path (adjust if needed)
|
||||||
|
# COPY --from=frontend-builder /app/web/dist ./web/dist
|
||||||
|
|
||||||
|
RUN CGO_ENABLED=0 GOOS=linux make build
|
||||||
|
|
||||||
|
# Stage 3: Final image
|
||||||
|
FROM debian:bookworm-slim
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Install CA certificates for HTTPS
|
||||||
|
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
COPY --from=backend-builder /app/bin/hspguard .
|
||||||
|
COPY --from=frontend-builder /app/dist ./dist
|
||||||
|
|
||||||
|
# Optional: copy default .env file if used
|
||||||
|
# COPY .env .env
|
||||||
|
|
||||||
|
# Set environment variables (can be overridden at runtime)
|
||||||
|
ENV ENV=production \
|
||||||
|
GUARD_PORT=3001 \
|
||||||
|
GUARD_HOST="127.0.0.1" \
|
||||||
|
GUARD_DB_URL="postgres://user:user@localhost:5432/db?sslmode=disable" \
|
||||||
|
GUARD_ADMIN_NAME="admin" \
|
||||||
|
GUARD_ADMIN_EMAIL="admin@test.net" \
|
||||||
|
GUARD_ADMIN_PASSWORD="secret" \
|
||||||
|
GUARD_JWT_PRIVATE="rsa" \
|
||||||
|
GUARD_JWT_PUBLIC="rsa" \
|
||||||
|
GUARD_JWT_KID="my-rsa-key-1" \
|
||||||
|
GUARD_JWT_ISSUER="http://localhost:3001" \
|
||||||
|
GUARD_MINIO_ENDPOINT="localhost:9000" \
|
||||||
|
GUARD_MINIO_ACCESS_KEY="" \
|
||||||
|
GUARD_MINIO_SECRET_KEY="" \
|
||||||
|
GOOSE_DRIVER="postgres" \
|
||||||
|
GOOSE_DBSTRING=$GUARD_DB_URL \
|
||||||
|
GOOSE_MIGRATION_DIR="./migrations"
|
||||||
|
|
||||||
|
EXPOSE 3001
|
||||||
|
|
||||||
|
CMD ["./hspguard"]
|
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
|
|
||||||
"gitea.local/admin/hspguard/cmd/hspguard/api"
|
"gitea.local/admin/hspguard/cmd/hspguard/api"
|
||||||
"gitea.local/admin/hspguard/internal/config"
|
"gitea.local/admin/hspguard/internal/config"
|
||||||
@ -16,9 +17,8 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
err := godotenv.Load()
|
err := godotenv.Load()
|
||||||
if err != nil {
|
if err != nil && os.Getenv("ENV") != "production" {
|
||||||
log.Fatalln("ERR: Failed to load environment variables:", err)
|
log.Fatalln("WARNING: .env file not found. Skipping...")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var cfg config.AppConfig
|
var cfg config.AppConfig
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
image: postgres
|
image: postgres
|
||||||
@ -9,4 +8,3 @@ services:
|
|||||||
POSTGRES_PASSWORD: guard
|
POSTGRES_PASSWORD: guard
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "5432:5432"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user