Skip to content

Commit

Permalink
make image based on distroless
Browse files Browse the repository at this point in the history
  • Loading branch information
logica0419 committed Dec 11, 2023
1 parent 72e9bba commit 70ca9f8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions .hadolint.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
ignored:
- DL3018
- DL3007
20 changes: 11 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
FROM --platform=$BUILDPLATFORM golang:1.21.5-alpine AS build
FROM golang:1.21.5 AS build
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN mkdir /storage

WORKDIR /go/src/github.com/traPtitech/traQ

COPY ./go.* ./
RUN --mount=type=cache,target=/go/pkg/mod go mod download

COPY . .

ENV GOCACHE=/tmp/go/cache
ENV CGO_ENABLED=0
ARG TRAQ_VERSION=dev
Expand All @@ -16,19 +18,19 @@ ARG TARGETARCH
ENV GOOS=$TARGETOS
ENV GOARCH=$TARGETARCH

COPY . .
RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/tmp/go/cache \
go build -o /traQ -ldflags "-s -w -X main.version=$TRAQ_VERSION -X main.revision=$TRAQ_REVISION"

FROM alpine:3.19.0
FROM gcr.io/distroless/base:latest
WORKDIR /app
EXPOSE 3000

RUN apk add --no-cache --update ca-certificates && update-ca-certificates
COPY --from=build /storage/ /app/storage/
VOLUME /app/storage

COPY --from=build /traQ ./

VOLUME /app/storage
EXPOSE 3000

HEALTHCHECK CMD ./traQ healthcheck || exit 1
HEALTHCHECK CMD ["./traQ", "healthcheck", "||", "exit", "1"]
ENTRYPOINT ["./traQ"]
CMD ["serve"]

0 comments on commit 70ca9f8

Please sign in to comment.