-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
12 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
FROM ubuntu:latest | ||
FROM golang:1.18 as builder | ||
|
||
RUN apt-get update | ||
RUN apt-get install -y wget git gcc bash | ||
|
||
RUN wget -P /tmp https://dl.google.com/go/go1.18.linux-amd64.tar.gz | ||
WORKDIR /app | ||
COPY . /app | ||
|
||
RUN tar -C /usr/local -xzf /tmp/go1.18.linux-amd64.tar.gz | ||
RUN rm /tmp/go1.18.linux-amd64.tar.gz | ||
RUN go get -d -v | ||
|
||
ENV GOPATH /go | ||
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH | ||
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" | ||
# Statically compile our app for use in a distroless container | ||
RUN CGO_ENABLED=0 go build -ldflags="-w -s" -v -o app . | ||
|
||
RUN go version | ||
FROM debian:buster-slim | ||
RUN set -x && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ | ||
ca-certificates git bash && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /app | ||
COPY . /app/ | ||
COPY --from=builder /app/app /app | ||
|
||
# Start app | ||
ENTRYPOINT ["go", "run", "/app/main.go"] | ||
ENTRYPOINT ["/app"] |