Skip to content

Commit

Permalink
add docker
Browse files Browse the repository at this point in the history
  • Loading branch information
imskr committed Jul 17, 2022
1 parent 1ea48aa commit 589a2a5
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions Dockerfile
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"]

0 comments on commit 589a2a5

Please sign in to comment.