add Dockerfile

This commit is contained in:
Denis 2026-03-31 11:34:50 +03:00
parent b340a339c3
commit f84e91ede2
4 changed files with 51 additions and 30 deletions

5
.dockerignore Normal file
View File

@ -0,0 +1,5 @@
.git
.idea
debug
uploads
.env

View File

@ -8,6 +8,8 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o server ./cmd/main.go
FROM alpine:3.18
RUN apk add --no-cache ca-certificates tzdata
WORKDIR /app
COPY --from=builder /app/server .
RUN mkdir -p /app/uploads/images
COPY --from=builder /app/server ./server
EXPOSE 8080
EXPOSE 50051
CMD ["./server"]

33
debug/docker-compose.yml Normal file
View File

@ -0,0 +1,33 @@
services:
postgres:
image: postgres:16
container_name: backend-postgres
restart: unless-stopped
ports:
- "${DB_PORT:-5432}:5432"
environment:
POSTGRES_DB: ${DB_NAME:-game_admin}
POSTGRES_USER: ${DB_USER:-game_admin_user}
POSTGRES_PASSWORD: ${DB_PASSWORD:-game_admin_password}
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-game_admin_user} -d ${DB_NAME:-game_admin}"]
interval: 10s
timeout: 5s
retries: 10
start_period: 15s
adminer:
image: adminer:4
container_name: backend-adminer
restart: unless-stopped
depends_on:
- postgres
ports:
- "${ADMINER_PORT:-8081}:8080"
environment:
ADMINER_DEFAULT_SERVER: postgres
volumes:
postgres_data:

View File

@ -1,33 +1,14 @@
services:
postgres:
image: postgres:16
container_name: backend-postgres
app:
build:
context: .
dockerfile: Dockerfile
container_name: backend-app
restart: unless-stopped
env_file:
- .env
ports:
- "${DB_PORT:-5432}:5432"
environment:
POSTGRES_DB: ${DB_NAME:-game_admin}
POSTGRES_USER: ${DB_USER:-game_admin_user}
POSTGRES_PASSWORD: ${DB_PASSWORD:-game_admin_password}
- "${SERVER_PORT:-8080}:8080"
- "${GRPC_PORT:-50051}:50051"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-game_admin_user} -d ${DB_NAME:-game_admin}"]
interval: 10s
timeout: 5s
retries: 10
start_period: 15s
adminer:
image: adminer:4
container_name: backend-adminer
restart: unless-stopped
depends_on:
- postgres
ports:
- "${ADMINER_PORT:-8081}:8080"
environment:
ADMINER_DEFAULT_SERVER: postgres
volumes:
postgres_data:
- ./uploads:/app/${UPLOAD_DIR:-uploads}