32 lines
713 B
Docker
32 lines
713 B
Docker
FROM golang:1.21-alpine as builder
|
|
|
|
WORKDIR /app
|
|
COPY . .
|
|
|
|
# Install build dependencies
|
|
RUN apk add --no-cache git build-base
|
|
|
|
# Build the frontend
|
|
RUN apk add --no-cache nodejs npm
|
|
RUN cd web && npm ci && npm run build
|
|
|
|
# Build the backend with embedded frontend
|
|
RUN go mod download
|
|
RUN go generate ./...
|
|
RUN go build -o inventory -ldflags="-s -w" .
|
|
|
|
# Create minimal runtime image
|
|
FROM alpine:latest
|
|
RUN apk --no-cache add ca-certificates tzdata
|
|
|
|
WORKDIR /app
|
|
COPY --from=builder /app/inventory .
|
|
COPY --from=builder /app/config.yaml ./config.yaml
|
|
|
|
# Create a non-root user to run the application
|
|
RUN adduser -D -H -h /app appuser
|
|
RUN chown -R appuser:appuser /app
|
|
USER appuser
|
|
|
|
EXPOSE 8088
|
|
CMD ["./inventory"]
|