modif Dockerfile
This commit is contained in:
37
Dockerfile
37
Dockerfile
@@ -1,28 +1,27 @@
|
|||||||
FROM golang:1.22-alpine AS builder
|
FROM golang:alpine as builder
|
||||||
|
|
||||||
WORKDIR /app
|
ARG ACCESS_TOKEN_USR="nothing"
|
||||||
|
ARG ACCESS_TOKEN_PWD="nothing"
|
||||||
|
|
||||||
# Copy go mod files
|
RUN apk add --no-cache ca-certificates tzdata git
|
||||||
COPY go.mod go.sum ./
|
|
||||||
|
|
||||||
# Download dependencies
|
WORKDIR /
|
||||||
RUN go mod download
|
|
||||||
|
# Create a netrc file using the credentials specified using --build-arg
|
||||||
|
RUN printf "machine git.coopgo.io\n\
|
||||||
|
login ${ACCESS_TOKEN_USR}\n\
|
||||||
|
password ${ACCESS_TOKEN_PWD}\n"\
|
||||||
|
>> ~/.netrc
|
||||||
|
RUN chmod 600 ~/.netrc
|
||||||
|
|
||||||
# Copy source code
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Build the application
|
RUN go mod download && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /server
|
||||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .
|
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM scratch
|
||||||
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||||
RUN apk --no-cache add ca-certificates
|
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
|
||||||
|
COPY --from=builder /server /
|
||||||
WORKDIR /root/
|
|
||||||
|
|
||||||
# Copy the binary from builder
|
|
||||||
COPY --from=builder /app/main .
|
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
ENTRYPOINT ["/server"]
|
||||||
CMD ["./main"]
|
|
||||||
|
|||||||
Reference in New Issue
Block a user