forked from moven/jitsu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configurator.Dockerfile
111 lines (79 loc) · 3.81 KB
/
configurator.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# BASE STAGE
FROM debian:bullseye-slim as main
# Install dependencies
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
RUN apt-get install -y --fix-missing bash python3 python3-pip python3-venv python3-dev sudo curl dnsutils
ARG TARGETARCH
ARG dhid
ENV DOCKER_HUB_ID=$dhid
ENV CONFIGURATOR_USER=configurator
ENV TZ=UTC
RUN echo "$CONFIGURATOR_USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \
&& addgroup --system $CONFIGURATOR_USER \
&& adduser --system $CONFIGURATOR_USER \
&& adduser $CONFIGURATOR_USER $CONFIGURATOR_USER \
&& mkdir -p /home/$CONFIGURATOR_USER/data/logs \
&& mkdir -p /home/$CONFIGURATOR_USER/data/config \
&& mkdir -p /home/$CONFIGURATOR_USER/app/web \
&& chown -R $CONFIGURATOR_USER:$CONFIGURATOR_USER /home/$CONFIGURATOR_USER
# Create symlink for backward compatibility
RUN ln -s /home/$CONFIGURATOR_USER/data/config /home/$CONFIGURATOR_USER/app/res && \
ln -s /home/$CONFIGURATOR_USER/data/logs /home/$CONFIGURATOR_USER/logs && \
chown -R $CONFIGURATOR_USER:$CONFIGURATOR_USER /home/$CONFIGURATOR_USER/logs
#######################################
# BUILD JS STAGE
FROM jitsucom/configurator-builder as jsbuilder
# Install yarn dependencies
ADD configurator/frontend/package.json /frontend/package.json
ARG SKIP_UI_BUILD
ENV SKIP_UI=$SKIP_UI_BUILD
WORKDIR /frontend
# Copy project
ADD configurator/frontend/. ./
# We need to make sure empty 'build' directory exists if SKIP_UI_BUILD==true and yarn won't make it
RUN mkdir -p ./main/build
# write the output of the date command into a file called tmp_variable
RUN free | awk 'FNR == 2 {print $2}' > ./main/build/mem
# Check RAM > 4gb else error (JS build requires >4gb RAM)
RUN if [ $(cat ./main/build/mem) < "4000000" ]; then echo echo Docker build requires 4gb of RAM. Configure it in the machine Docker configuration && exit 1; else rm ./main/build/mem; fi
# Install dependencies
RUN if [ "$SKIP_UI" != "true" ]; then yarn install --prefer-offline --frozen-lockfile --network-timeout 1000000; fi
# Build
RUN if [ "$SKIP_UI" != "true" ]; then CI=false ANALYTICS_KEYS='{"eventnative": "js.gpon6lmpwquappfl07tuq.ka5sxhsm08cmblny72tevi"}' yarn build; fi
#######################################
# BUILD BACKEND STAGE
FROM jitsucom/jitsu-builder:$TARGETARCH as builder
ENV CONFIGURATOR_USER=configurator
RUN mkdir -p /go/src/github.com/jitsucom/jitsu/$CONFIGURATOR_USER/backend && \
mkdir -p /go/src/github.com/jitsucom/jitsu/server
WORKDIR /go/src/github.com/jitsucom/jitsu/$CONFIGURATOR_USER/backend
#Caching dependencies
ADD configurator/backend/go.mod ./
ADD server/go.mod /go/src/github.com/jitsucom/jitsu/server/
RUN go mod download
#tmp workaround until next version of v8go will be release
RUN git clone https://github.com/rogchap/v8go.git /tmp/[email protected]
RUN cp -fr /tmp/[email protected]/* /root/go/pkg/mod/rogchap.com/[email protected]
#Copy backend
ADD openapi /go/src/github.com/jitsucom/jitsu/openapi
ADD configurator/backend/. ./.
ADD server /go/src/github.com/jitsucom/jitsu/server
ADD .git /go/src/github.com/jitsucom/jitsu/.git
# Build
RUN make docker_assemble
#######################################
# FINAL STAGE
FROM main as final
# copy static files from build-image
COPY --from=builder /go/src/github.com/jitsucom/jitsu/$CONFIGURATOR_USER/backend/build/dist /home/$CONFIGURATOR_USER/app
COPY --from=jsbuilder /frontend/main/build /home/$CONFIGURATOR_USER/app/web
RUN chown -R $CONFIGURATOR_USER:$CONFIGURATOR_USER /home/$CONFIGURATOR_USER/app
ADD configurator/backend/entrypoint.sh /home/$CONFIGURATOR_USER/entrypoint.sh
RUN chmod +x /home/$CONFIGURATOR_USER/entrypoint.sh
USER $CONFIGURATOR_USER
WORKDIR /home/$CONFIGURATOR_USER/app
COPY docker/configurator.yaml /home/$CONFIGURATOR_USER/data/config/
VOLUME ["/home/$CONFIGURATOR_USER/data"]
EXPOSE 7000
ENTRYPOINT /home/$CONFIGURATOR_USER/entrypoint.sh