mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 07:32:32 +01:00
refactor(docker): improve Docker setup and reduce image size
- Add multi-stage build to Dockerfile for smaller production image - Move docker-compose.yml to project root for easier usage - Flatten docker/init/setup.sh to docker/setup.sh - Expand .dockerignore to exclude unnecessary files - Remove deprecated version field from compose files
This commit is contained in:
@@ -1 +1,35 @@
|
|||||||
|
# Build artifacts
|
||||||
bin/
|
bin/
|
||||||
|
erupe-ce
|
||||||
|
*.exe
|
||||||
|
|
||||||
|
# Docker data directories
|
||||||
|
docker/db-data/
|
||||||
|
docker/savedata/
|
||||||
|
docker/Servers/
|
||||||
|
|
||||||
|
# IDE and editor files
|
||||||
|
.idea/
|
||||||
|
.vscode/
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
*~
|
||||||
|
|
||||||
|
# Git
|
||||||
|
.git/
|
||||||
|
.gitignore
|
||||||
|
|
||||||
|
# Documentation and config examples
|
||||||
|
*.md
|
||||||
|
!README.md
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
config.json
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs/
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# Test artifacts
|
||||||
|
coverage.out
|
||||||
|
*.test
|
||||||
|
|||||||
17
Dockerfile
17
Dockerfile
@@ -1,4 +1,5 @@
|
|||||||
FROM golang:1.25-alpine3.21
|
# Build stage
|
||||||
|
FROM golang:1.25-alpine3.21 AS builder
|
||||||
|
|
||||||
ENV GO111MODULE=on
|
ENV GO111MODULE=on
|
||||||
|
|
||||||
@@ -11,4 +12,16 @@ RUN go mod download
|
|||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
CMD [ "go", "run", "." ]
|
RUN CGO_ENABLED=0 GOOS=linux go build -o erupe-ce .
|
||||||
|
|
||||||
|
# Runtime stage
|
||||||
|
FROM alpine:3.21
|
||||||
|
|
||||||
|
RUN apk --no-cache add ca-certificates tzdata
|
||||||
|
|
||||||
|
WORKDIR /app/erupe
|
||||||
|
|
||||||
|
COPY --from=builder /app/erupe/erupe-ce .
|
||||||
|
|
||||||
|
# Default command runs the compiled binary
|
||||||
|
CMD [ "./erupe-ce" ]
|
||||||
|
|||||||
@@ -1,23 +1,20 @@
|
|||||||
version: "3.9"
|
# Root-level docker-compose for easy usage: docker compose up
|
||||||
# 1. docker-compose up db pgadmin
|
# For development: docker compose up db pgadmin
|
||||||
# 2. Use pgadmin to restore db and also apply patch-schema
|
# For full stack: docker compose up
|
||||||
# 3. Configure the config.json example. in docker you can point to the service name for the database i.e db
|
|
||||||
# 4. In seperate terminal docker-compose up server
|
|
||||||
# 5. If all went well happy hunting!
|
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
image: postgres
|
image: postgres
|
||||||
environment:
|
environment:
|
||||||
# (Make sure these match config.json)
|
# (Make sure these match config.json)
|
||||||
- POSTGRES_USER=postgres
|
- POSTGRES_USER=postgres
|
||||||
- POSTGRES_PASSWORD=password
|
- POSTGRES_PASSWORD=password
|
||||||
- POSTGRES_DB=erupe
|
- POSTGRES_DB=erupe
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "5432:5432"
|
||||||
volumes:
|
volumes:
|
||||||
- ./db-data/:/var/lib/postgresql/data/
|
- ./docker/db-data/:/var/lib/postgresql/data/
|
||||||
- ../schemas/:/schemas/
|
- ./schemas/:/schemas/
|
||||||
- ./init/setup.sh:/docker-entrypoint-initdb.d/setup.sh
|
- ./docker/setup.sh:/docker-entrypoint-initdb.d/setup.sh
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||||
interval: 5s
|
interval: 5s
|
||||||
@@ -38,13 +35,12 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
db:
|
db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
# If using prebuilt container change paths and config
|
|
||||||
build:
|
build:
|
||||||
context: ../
|
context: .
|
||||||
volumes:
|
volumes:
|
||||||
- ../config.json:/app/erupe/config.json
|
- ./config.json:/app/erupe/config.json
|
||||||
- ../bin:/app/erupe/bin
|
- ./bin:/app/erupe/bin
|
||||||
- ./savedata:/app/erupe/savedata
|
- ./docker/savedata:/app/erupe/savedata
|
||||||
ports:
|
ports:
|
||||||
# (Make sure these match config.json)
|
# (Make sure these match config.json)
|
||||||
- "53312:53312" #Sign V1
|
- "53312:53312" #Sign V1
|
||||||
@@ -65,7 +61,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- '80:80'
|
- '80:80'
|
||||||
volumes:
|
volumes:
|
||||||
- ./Servers:/usr/local/apache2/htdocs
|
- ./docker/Servers:/usr/local/apache2/htdocs
|
||||||
depends_on:
|
depends_on:
|
||||||
db:
|
db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# Docker Compose configuration for running integration tests
|
# Docker Compose configuration for running integration tests
|
||||||
# Usage: docker-compose -f docker/docker-compose.test.yml up -d
|
# Usage: docker compose -f docker/docker-compose.test.yml up -d
|
||||||
services:
|
services:
|
||||||
test-db:
|
test-db:
|
||||||
image: postgres:15-alpine
|
image: postgres:15-alpine
|
||||||
|
|||||||
Reference in New Issue
Block a user