-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.spaceapi
More file actions
43 lines (30 loc) · 1003 Bytes
/
Dockerfile.spaceapi
File metadata and controls
43 lines (30 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
FROM golang:1.21-alpine AS builder
WORKDIR /app
# Copy go mod files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy source code
COPY cmd/ ./cmd/
COPY internal/ ./internal/
# Build the application
ARG VERSION=dev
ARG COMMIT=unknown
ARG DATE=unknown
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo \
-ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" \
-o spaceapi ./cmd/spaceapi
# Final stage
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /app
# Copy the binary
COPY --from=builder /app/spaceapi .
# Create a sample config file for reference (will be overridden by volume mount)
COPY spaceapi.json.example ./spaceapi.json.example
# Expose port
EXPOSE 8080
# The spaceapi.json file should be mounted from the host at /app/spaceapi.json
# Example: docker run -v /path/to/your/spaceapi.json:/app/spaceapi.json:ro -p 8080:8080 ghcr.io/q30-space/spaceapi:latest
# Run the binary
CMD ["./spaceapi"]