diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8d7b2f0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM alpine as build + +ADD ./build/app /app + +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \ + && apk --no-cache add ca-certificates + +FROM scratch +# copy the ca-certificate.crt from the build stage +COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +COPY --from=build /app /app + +EXPOSE 13721 + +ENTRYPOINT ["/app"] \ No newline at end of file diff --git a/Makefile b/Makefile index 34949ad..26bb10c 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ include .env include .env.local -.PHONY: proto +.PHONY: build proto run: go run cmd/mp-server/main.go \ @@ -15,6 +15,13 @@ clean: all: api +build: + CGO_ENABLED=0 GOOS="linux" GOARCH="amd64" \ + go build -o ./build/app -ldflags="-s -w" -tags timetzdata ./cmd/mp-server + upx build/app + docker build -t esinio/weixin:mp-auth . + rm build/app + docker.push: docker push esinio/weixin:oauth2