forked from cloud-barista/mc-data-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
41 lines (39 loc) · 1.37 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
##############################################################
## Stage 1 - Go Build As builder
##############################################################
FROM golang:1.23 AS builder
WORKDIR /opt
COPY . .
RUN go build -o app .
#############################################################
## Stage 2 - Application Setup AS prod
##############################################################
FROM ubuntu:22.04 AS prod
ARG UID=0
ARG GID=0
ARG USER=root
ARG GROUP=root
#-------------------------------------------------------------
RUN apt-get update
RUN apt-get install ca-certificates -y
#-------------------------------------------------------------
# User Set
RUN if [ "${USER}" != "root" ]; then \
groupadd -g ${GID} ${GROUP} && \
useradd -m -u ${UID} -g ${GID} -s /bin/bash ${USER}; \
fi
#-------------------------------------------------------------
# Copy App and Web
RUN mkdir -p /app/log
RUN chown -R ${USER}:${GROUP} /app
USER ${USER}
COPY --from=builder --chown=${USER}:${GROUP} /opt/app /app/app
COPY --from=builder --chown=${USER}:${GROUP} /opt/web /app/web
#-------------------------------------------------------------
# Add entrypoint script
COPY --chown=${USER}:${GROUP} entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
#-------------------------------------------------------------
WORKDIR /app
EXPOSE 3300
ENTRYPOINT ["/app/entrypoint.sh"]