feat: some refactoring
This commit is contained in:
31
build/Dockerfile
Normal file
31
build/Dockerfile
Normal file
@@ -0,0 +1,31 @@
|
||||
# Build stage
|
||||
FROM golang:1.25-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy go mod files
|
||||
COPY go.mod go.sum ./
|
||||
|
||||
# Download dependencies
|
||||
RUN go mod download
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Build the application
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o apiserver ./cmd/apiserver
|
||||
|
||||
# Final stage
|
||||
FROM alpine:latest
|
||||
|
||||
WORKDIR /root/
|
||||
|
||||
# Copy binary from builder stage
|
||||
COPY --from=builder /app/apiserver .
|
||||
COPY --from=builder /app/configs ./configs
|
||||
|
||||
# Expose port
|
||||
EXPOSE 8080
|
||||
|
||||
# Run the application
|
||||
CMD ["./apiserver", "--config-path=./configs/server.toml"]
|
||||
23
build/docker-compose.yml
Normal file
23
build/docker-compose.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
apiserver:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: build/Dockerfile
|
||||
container_name: mygoserver
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- ../configs:/root/configs:ro
|
||||
environment:
|
||||
- LOGGING_LEVEL=info
|
||||
- LOGGING_FORMAT=json
|
||||
- LOGGING_OUTPUT=stdout
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- app-network
|
||||
|
||||
networks:
|
||||
app-network:
|
||||
driver: bridge
|
||||
Reference in New Issue
Block a user