mirror of
https://github.com/yanislav-igonin/micrach
synced 2026-07-27 05:14:17 +03:00
build: add multi-stage image
This commit is contained in:
parent
ce11d6ff5e
commit
c09684e2fa
11
.dockerignore
Normal file
11
.dockerignore
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
.git
|
||||||
|
.github
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
docs
|
||||||
|
tests
|
||||||
|
uploads
|
||||||
|
micrach
|
||||||
|
*.out
|
||||||
|
*.test
|
||||||
30
Dockerfile
30
Dockerfile
@ -1,8 +1,24 @@
|
|||||||
FROM busybox
|
FROM golang:1.26.5-alpine3.24 AS build
|
||||||
|
|
||||||
|
WORKDIR /src
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
RUN go mod download
|
||||||
|
COPY . .
|
||||||
|
RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/micrach .
|
||||||
|
|
||||||
|
FROM alpine:3.24.1
|
||||||
|
|
||||||
|
RUN apk add --no-cache ca-certificates \
|
||||||
|
&& addgroup -S micrach \
|
||||||
|
&& adduser -S -G micrach micrach \
|
||||||
|
&& mkdir -p /app/uploads \
|
||||||
|
&& chown -R micrach:micrach /app
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY templates/ templates/
|
COPY --from=build /out/micrach ./micrach
|
||||||
COPY static/ static/
|
COPY --chown=micrach:micrach templates/ templates/
|
||||||
COPY migrations/ migrations/
|
COPY --chown=micrach:micrach static/ static/
|
||||||
COPY micrach ./
|
COPY --chown=micrach:micrach migrations/ migrations/
|
||||||
RUN chmod +x /app/micrach
|
|
||||||
ENTRYPOINT ["/app/micrach"]
|
USER micrach
|
||||||
|
ENTRYPOINT ["./micrach"]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user