1 Star 0 Fork 2

xmlgrg/go-gin-rest-api

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Dockerfile 2.11 KB
一键复制 编辑 原始数据 按行查看 历史
linclin 提交于 2024-09-21 15:15 . cron定时任务panic问题修复
# syntax=registry.cn-shenzhen.aliyuncs.com/dev-ops/dockerfile:1.9.0
FROM registry.cn-shenzhen.aliyuncs.com/dev-ops/golang:1.23.1-alpine3.20 as golang
ENV APP go-gin-rest-api
RUN sed -i 's/https/http/' /etc/apk/repositories && \
sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
apk update && \
apk add --no-cache ca-certificates git && \
rm -rf /var/cache/apk/* /tmp/*
ADD ./ /app/go-gin-rest-api
ADD .git/ /app/go-gin-rest-api/.git
WORKDIR /app/go-gin-rest-api
RUN export GitBranch=$(git name-rev --name-only HEAD) && \
export GitRevision=$(git rev-parse --short HEAD) && \
export GitCommitLog=`git log --pretty=oneline -n 1` && \
export BuildTime=`date +'%Y.%m.%d.%H%M%S'` && \
export BuildGoVersion=`go version` && \
export LDFlags="-s -w -X 'main.GitBranch=${GitBranch}' -X 'main.GitRevision=${GitRevision}' -X 'main.GitCommitLog=${GitCommitLog}' -X 'main.BuildTime=${BuildTime}' -X 'main.BuildGoVersion=${BuildGoVersion}'" && \
go build -tags=jsoniter -ldflags="$LDFlags" -o ./go-gin-rest-api
FROM registry.cn-shenzhen.aliyuncs.com/dev-ops/alpine:3.20.3
LABEL MAINTAINER="13579443@qq.com"
ENV TZ='Asia/Shanghai'
ENV LANG UTF-8
ENV LC_ALL zh_CN.UTF-8
ENV LC_CTYPE zh_CN.UTF-8
RUN TERM=linux && export TERM
RUN sed -i 's/https/http/' /etc/apk/repositories && \
sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
apk update && \
apk add --no-cache ca-certificates tzdata bash sudo busybox-extras curl && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtim && \
echo "Asia/Shanghai" > /etc/timezone && \
rm -rf /var/cache/apk/* /tmp/* && \
addgroup -g 1000 app && \
adduser -u 1000 -G app -D app && \
adduser -u 1001 -G app -D dev && \
chmod 4755 /bin/busybox && \
mkdir -p /app && \
chown -R app:app /app
WORKDIR /app/go-gin-rest-api/
COPY --from=golang --chown=app:app --chmod=755 /app/go-gin-rest-api/go-gin-rest-api /app/go-gin-rest-api/go-gin-rest-api
COPY --from=golang --chown=app:app --chmod=755 /app/go-gin-rest-api/conf /app/go-gin-rest-api/conf
CMD ["./go-gin-rest-api"]
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/xmlgrg/go-gin-rest-api.git
git@gitee.com:xmlgrg/go-gin-rest-api.git
xmlgrg
go-gin-rest-api
go-gin-rest-api
main

搜索帮助