This commit is contained in:
gotoeasy 2022-09-24 12:24:26 +08:00
parent 6fc51d0faa
commit 022b51aaaf
2 changed files with 1 additions and 44 deletions

1
.gitignore vendored
View File

@ -17,3 +17,4 @@
/**/dist/
/**/node_modules/
/glc/glc
/glc/Dockerfile

View File

@ -1,44 +0,0 @@
# ----------------------------
# 编译Web
# ----------------------------
FROM node:14-alpine3.15 AS webbuilder
WORKDIR /webproject
COPY . /webproject
RUN cd www/web && \
yarn install --registry https://registry.npm.taobao.org && \
yarn run build
# ----------------------------
# 编译Go
# ----------------------------
FROM golang:1.19-alpine AS gobuilder
WORKDIR /goproject
COPY . /goproject
COPY --from=webbuilder /webproject/www/web/dist www/web/
ENV GOPROXY https://goproxy.cn,direct
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-w -s"
# ----------------------------
# 打包镜像
# ----------------------------
FROM alpine AS runner
MAINTAINER gotoeasy <gotoeasy@163.com>
COPY --from=gobuilder /goproject/glc /usr/local/bin/
# 安装bash、设定默认时区
RUN alpine_version=`cat /etc/issue | head -1 | awk '{print $5}'` \
&& echo "https://mirrors.aliyun.com/alpine/v${alpine_version}/main/" > /etc/apk/repositories \
&& apk update && apk upgrade && apk add --no-cache bash bash-doc bash-completion tzdata \
&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" > /etc/timezone \
&& rm -rf /var/cache/apk/*
EXPOSE 8080
ENTRYPOINT ["glc"]