-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile-Build
executable file
·44 lines (33 loc) · 1.16 KB
/
Dockerfile-Build
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#Copyright © 2024 chaoxin.lu
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# 打包依赖阶段使用golang作为基础镜像
FROM golang:1.23 as builder
USER root
WORKDIR /app
ENV GO111MODULE=on \
GOPROXY=https://goproxy.cn,direct
COPY . .
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-w -s" main.go
# 运行阶段指定alpine作为基础镜像
FROM alpine
LABEL maintainer="chaoxin.lu"
WORKDIR /app
# 将上一个阶段app文件夹下的所有文件复制进来
COPY --from=builder /app/main .
COPY templates/* /app/templates/
COPY static/* /app/static/
# 指定运行时环境变量
ENV GIN_MODE=release \
SERVER_PORT=6666
ENTRYPOINT ["./main"]