-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdockerfile
27 lines (25 loc) · 947 Bytes
/
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
FROM golang:alpine AS build
LABEL [email protected]
ARG APP_VERSION
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN go env -w GOPROXY=https://goproxy.cn,direct
RUN go install golang.org/x/tools/cmd/goimports@latest
WORKDIR /app
COPY . .
RUN go build \
-mod=vendor \
-ldflags="-s -w" \
-o sql2struct main.go
FROM alpine:latest
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
apk update --no-cache && apk add --no-cache tzdata && \
ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone ;
RUN export PATH=$PATH:/go/bin
COPY --from=build /app/sql2struct /bin/sql2struct
COPY --from=build /go/bin/goimports /bin/goimports
COPY --from=build /usr/local/go/bin/gofmt /bin/gofmt
RUN mkdir -p /workspace && \
chmod +x /bin/sql2struct /bin/goimports /bin/gofmt
WORKDIR /workspace
ENTRYPOINT ["sql2struct"]