Add Docker support with Dockerfile, entrypoint script, and CI workflows
- Introduced a Dockerfile for building the application with Go and Node.js dependencies. - Added a docker-entrypoint.sh script to manage container execution. - Created a .dockerignore file to exclude unnecessary files from the Docker context. - Updated Makefile to include a new target for building the Docker image. - Added CI workflows for testing, formatting, and releasing artifacts in Gitea.
This commit is contained in:
+39
@@ -0,0 +1,39 @@
|
||||
FROM golang:1.25-alpine AS builder
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
# Build-time dependencies for UI and Go compilation.
|
||||
RUN apk add --no-cache nodejs npm
|
||||
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
COPY web/ui/package.json web/ui/package-lock.json ./web/ui/
|
||||
RUN npm --prefix ./web/ui ci
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN npm --prefix ./web/ui run build
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
|
||||
go build -trimpath -tags "netgo osusergo" -ldflags "-s -w" \
|
||||
-o /out/scratchbox ./cmd/scratchbox
|
||||
|
||||
FROM alpine:3.22
|
||||
|
||||
RUN addgroup -S scratchbox && adduser -S -G scratchbox scratchbox
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /out/scratchbox /usr/local/bin/scratchbox
|
||||
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
||||
|
||||
RUN chmod +x /usr/local/bin/docker-entrypoint.sh && \
|
||||
mkdir -p /data /config && chown -R scratchbox:scratchbox /data /config
|
||||
|
||||
USER scratchbox
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
VOLUME ["/data", "/config"]
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
||||
Reference in New Issue
Block a user