-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
46 lines (32 loc) · 1.15 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# syntax = docker/dockerfile:latest
FROM golang:1.19.1-alpine3.16 AS build
ARG GOPATH="/go"
ARG GOMODCACHE=${GOPATH}/pkg/mod
ARG GOCACHE="/root/.cache/go-build"
ENV GOMODCACHE=${GOMODCACHE}
ENV GOCACHE=${GOCACHE}
WORKDIR /go/src/app
RUN apk update && \
apk add build-base
COPY go.* ./
RUN --mount=type=cache,mode=0777,target=${GOCACHE} \
--mount=type=cache,mode=0777,target=${GOMODCACHE} \
go mod download
COPY . ./
RUN --mount=type=cache,mode=0777,target=${GOCACHE} \
--mount=type=cache,mode=0777,target=${GOMODCACHE} \
go build -o /tmp/app
FROM alpine
WORKDIR /app
ENV MODE="docker"
ENV DOCKERIZE_VERSION=v0.6.1
RUN set -ex; \
apk update && \
apk add --no-cache wget build-base && \
wget https://github.com/jwilder/dockerize/releases/download/${DOCKERIZE_VERSION}/dockerize-alpine-linux-amd64-${DOCKERIZE_VERSION}.tar.gz && \
tar -C /usr/local/bin -xzvf dockerize-alpine-linux-amd64-${DOCKERIZE_VERSION}.tar.gz && \
rm dockerize-alpine-linux-amd64-${DOCKERIZE_VERSION}.tar.gz
COPY assets database .env.docker ./
COPY --from=build /tmp/app ./
ENTRYPOINT [ "dockerize", "-template", ".env.example:.env", "./app"]
CMD ["-h"]