mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-23 08:03:51 +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/
|
||||
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
|
||||
|
||||
@@ -11,4 +12,16 @@ RUN go mod download
|
||||
|
||||
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"
|
||||
# 1. docker-compose up db pgadmin
|
||||
# 2. Use pgadmin to restore db and also apply patch-schema
|
||||
# 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!
|
||||
# Root-level docker-compose for easy usage: docker compose up
|
||||
# For development: docker compose up db pgadmin
|
||||
# For full stack: docker compose up
|
||||
services:
|
||||
db:
|
||||
image: postgres
|
||||
environment:
|
||||
# (Make sure these match config.json)
|
||||
# (Make sure these match config.json)
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=password
|
||||
- POSTGRES_DB=erupe
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- ./db-data/:/var/lib/postgresql/data/
|
||||
- ../schemas/:/schemas/
|
||||
- ./init/setup.sh:/docker-entrypoint-initdb.d/setup.sh
|
||||
- ./docker/db-data/:/var/lib/postgresql/data/
|
||||
- ./schemas/:/schemas/
|
||||
- ./docker/setup.sh:/docker-entrypoint-initdb.d/setup.sh
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||
interval: 5s
|
||||
@@ -38,13 +35,12 @@ services:
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
# If using prebuilt container change paths and config
|
||||
build:
|
||||
context: ../
|
||||
context: .
|
||||
volumes:
|
||||
- ../config.json:/app/erupe/config.json
|
||||
- ../bin:/app/erupe/bin
|
||||
- ./savedata:/app/erupe/savedata
|
||||
- ./config.json:/app/erupe/config.json
|
||||
- ./bin:/app/erupe/bin
|
||||
- ./docker/savedata:/app/erupe/savedata
|
||||
ports:
|
||||
# (Make sure these match config.json)
|
||||
- "53312:53312" #Sign V1
|
||||
@@ -65,7 +61,7 @@ services:
|
||||
ports:
|
||||
- '80:80'
|
||||
volumes:
|
||||
- ./Servers:/usr/local/apache2/htdocs
|
||||
- ./docker/Servers:/usr/local/apache2/htdocs
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
@@ -1,5 +1,5 @@
|
||||
# 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:
|
||||
test-db:
|
||||
image: postgres:15-alpine
|
||||
|
||||
Reference in New Issue
Block a user