add Dockerfile and docker-compose for multi-stage build; update .gitignore and various HTML examples
This commit is contained in:
24
Dockerfile
Normal file
24
Dockerfile
Normal file
@@ -0,0 +1,24 @@
|
||||
# Multi-stage Dockerfile for Go (PocketBase) project
|
||||
# --- Build Stage ---
|
||||
FROM golang:1.21-alpine AS builder
|
||||
WORKDIR /app
|
||||
COPY go.mod .
|
||||
COPY go.sum .
|
||||
RUN go mod download
|
||||
COPY . .
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -o server main.go
|
||||
|
||||
# --- Development Stage ---
|
||||
FROM golang:1.21-alpine AS dev
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app /app
|
||||
EXPOSE 8080
|
||||
CMD ["go", "run", "main.go"]
|
||||
|
||||
# --- Production Stage ---
|
||||
FROM alpine:3.18 AS prod
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/server /app/server
|
||||
COPY pb_public /app/pb_public
|
||||
EXPOSE 8080
|
||||
CMD ["/app/server"]
|
||||
Reference in New Issue
Block a user