docker
This commit is contained in:
parent
ee8fa9eb9d
commit
4eae8f44af
23
Dockerfile
Normal file
23
Dockerfile
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# 使用Alpine Linux作为基础镜像
|
||||
FROM golang:1.20-alpine
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 安装git,克隆代码仓库,编译应用,然后卸载git
|
||||
RUN echo 'nameserver 1.1.1.1' > /etc/resolv.conf && \
|
||||
apk add --no-cache git && \
|
||||
git clone https://gitlab.ni-co.moe/shira/temp-mail-receiver.git /tmp/code && \
|
||||
cd /tmp/code && \
|
||||
go build -o /app/myapp && \
|
||||
cp generate-config.sh /app/generate-config.sh && \
|
||||
cd /app && \
|
||||
rm -rf /tmp/code && \
|
||||
apk del git
|
||||
|
||||
# 赋予脚本执行权限
|
||||
RUN chmod +x /app/generate-config.sh
|
||||
|
||||
# 设置启动命令
|
||||
ENTRYPOINT ["/app/generate-config.sh"]
|
||||
CMD ["/app/myapp", "-c", "config.json"]
|
||||
11
generate-config.sh
Normal file
11
generate-config.sh
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/ash
|
||||
|
||||
# 使用环境变量生成config.json
|
||||
echo "{
|
||||
\"addr\": \"$ADDR\",
|
||||
\"api_url\": \"$API_URL\",
|
||||
\"api_key\": $API_KEY
|
||||
}" > config.json
|
||||
|
||||
# 执行传入的命令
|
||||
exec "$@"
|
||||
Loading…
Reference in New Issue
Block a user