Skip to content

Commit

Permalink
fix: Hadolint issue DL3018 & 3045
Browse files Browse the repository at this point in the history
  • Loading branch information
sbp-bvanb committed Dec 3, 2024
1 parent b0c5573 commit 67dc488
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.vscode
.task
.vscode
38 changes: 24 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
FROM golang:1.23.3-alpine as builder

RUN apk update && apk add --no-cache git ca-certificates tzdata && update-ca-certificates

RUN mkdir /app
FROM golang:1.23.3-alpine AS builder
ENV CGO_ENABLED=0 \
GOARCH=amd64 \
GOOS=linux \
PROJECT_NAME=mcvs-integrationtest-services
WORKDIR /app

COPY go.mod go.sum ./

RUN go mod download
COPY . .

ARG APPLICATION=mcvs-integrationtest-services
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o main ./cmd/$APPLICATION
RUN apk update && \
apk add \
--no-cache \
ca-certificates=~20240705-r0 \
git=~2 \
tzdata=~2024 && \
update-ca-certificates && \
go mod download && \
go build \
-a \
-installsuffix cgo \
-o main \
./cmd/${PROJECT_NAME} && \
adduser -D -u 1000 ${PROJECT_NAME}

FROM scratch
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /app/main ./main
CMD ["./main"]
COPY --from=builder /app/main /app/main
USER mcvs-integrationtest-services
ENTRYPOINT ["/app/main"]

0 comments on commit 67dc488

Please sign in to comment.