-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
60 lines (46 loc) · 1.35 KB
/
Dockerfile
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
ARG GO_VERSION=1.22
FROM golang:${GO_VERSION} AS builder
ARG APP_BUILD_DIR=/go/src/app
ARG APP_RUN_DIR=/go/src/app
#ARG MYGID=1001
#ARG MYUID=1001
#ARG APP_USER=user01
#ARG APP_GROUP=group01
#ENV MYGID=${MYGID}
#ENV MYUID=${MYUID}
#ENV APP_USER=${APP_USER}
#ENV APP_GROUP=${APP_GROUP}
# for debian
#RUN groupadd --gid $GID $APP_GROUP && useradd -m -l --uid $UID --gid $GID $APP_USER
#RUN mkdir -p $APP_DIR && chown -R $APP_USER:$APP_USER $APP_DIR
# for alpine
#RUN echo "1111111111111 ${MYGID} ${APP_GROUP}"
#RUN groupadd -g ${MYGID} -o ${APP_GROUP}
#RUN useradd -g $MYGID -o $APP_USER -u $MYUID -d /home/$APP_USER
#USER $APP_USER
WORKDIR $APP_BUILD_DIR
#COPY . .
COPY . $APP_BUILD_DIR
RUN go get -d -v ./...
RUN go mod download
RUN go build -o main
# run phase
FROM golang:${GO_VERSION}
ARG APP_BUILD_DIR=/go/src/app
ARG APP_RUN_DIR=/go/src/app
ENV STORAGE_DIR=/storage
#ENV CACHE_DIR=$STORAGE_DIR/cachedir
#ENV MIRROR_DIR=$STORAGE_DIR/mirrordir
#ENV CONFIG_DIR=$STORAGE_DIR/configdir
ENV CONFIG_DIR=/config
#VOLUME $CACHE_DIR
#VOLUME $MIRROR_DIR
EXPOSE 8080
RUN #apk --no-cache add ca-certificates
WORKDIR $APP_RUN_DIR
COPY --from=builder $APP_BUILD_DIR/main $APP_RUN_DIR/main
COPY --from=builder $APP_BUILD_DIR/templates $APP_RUN_DIR/templates
#ENTRYPOINT "ulimit -v $((1024*1024*1024)) && ./main"
#CMD ["./main"]
# 256MB
CMD "ulimit -v $((256*1024*1024)) && ./main"