forked from jitsucom/jitsu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.Dockerfile
107 lines (81 loc) · 3.65 KB
/
server.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
# 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
#install docker
RUN apt-get install apt-transport-https ca-certificates curl gnupg lsb-release -y
RUN curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
RUN apt-get update
RUN apt-get install -y docker-ce docker-ce-cli containerd.io
# Install node
RUN curl -o- -sL https://deb.nodesource.com/setup_16.x | bash
RUN apt-get install nodejs
RUN npm install -g [email protected] [email protected]
ARG TARGETARCH
ARG dhid
ARG SDK_VERSION=latest
ENV DOCKER_HUB_ID=$dhid
ENV TZ=UTC
ENV EVENTNATIVE_USER=eventnative
RUN echo "$EVENTNATIVE_USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \
&& addgroup --system $EVENTNATIVE_USER \
&& adduser --system $EVENTNATIVE_USER \
&& adduser $EVENTNATIVE_USER $EVENTNATIVE_USER \
&& adduser $EVENTNATIVE_USER docker \
&& adduser $EVENTNATIVE_USER daemon \
&& adduser $EVENTNATIVE_USER root \
&& adduser $EVENTNATIVE_USER bin \
&& mkdir -p /home/$EVENTNATIVE_USER/data/logs/events \
&& mkdir -p /home/$EVENTNATIVE_USER/data/config \
&& mkdir -p /home/$EVENTNATIVE_USER/data/venv \
&& mkdir -p /home/$EVENTNATIVE_USER/data/airbyte \
&& mkdir -p /home/$EVENTNATIVE_USER/app/ \
&& chown -R $EVENTNATIVE_USER:$EVENTNATIVE_USER /home/$EVENTNATIVE_USER \
&& echo "if [ -e /var/run/docker.sock ]; then sudo chmod 666 /var/run/docker.sock; fi" > /home/eventnative/.bashrc
# Create symlink for backward compatibility
RUN ln -s /home/$EVENTNATIVE_USER/data/config /home/$EVENTNATIVE_USER/app/res && \
ln -s /home/$EVENTNATIVE_USER/data/logs /home/$EVENTNATIVE_USER/logs && \
chown -R $EVENTNATIVE_USER:$EVENTNATIVE_USER /home/$EVENTNATIVE_USER/logs
# Download SDK npm package
RUN mkdir -p /home/$EVENTNATIVE_USER/app/web && \
curl -o /home/$EVENTNATIVE_USER/app/web/lib.js https://unpkg.com/@jitsu/sdk-js@$SDK_VERSION/dist/web/lib.js
# Copy js
ADD server/web /go/src/github.com/jitsucom/jitsu/server/web
ADD server/Makefile /go/src/github.com/jitsucom/jitsu/server/Makefile
WORKDIR /go/src/github.com/jitsucom/jitsu/server
# Build js (for caching) and copy builded files
RUN make assemble_js && cp -r ./build/dist/* /home/$EVENTNATIVE_USER/app/
#######################################
# BUILD BACKEND STAGE
FROM jitsucom/jitsu-builder:$TARGETARCH as builder
RUN mkdir /app
WORKDIR /go/src/github.com/jitsucom/jitsu/server
#Caching dependencies
ADD server/go.mod ./
RUN go mod download
#Copy backend
ADD server/. ./.
ADD .git ./.git
# Build backend and copy builded files
RUN make docker_assemble &&\
cp -r ./build/dist/* /app
#######################################
# FINAL STAGE
FROM main as final
ENV TZ=UTC
ENV NODE_PATH=/usr/lib/node_modules
WORKDIR /home/$EVENTNATIVE_USER/app
# copy static files from build-image
COPY --from=builder /app .
COPY docker/eventnative.yaml /home/$EVENTNATIVE_USER/data/config/
RUN chown -R $EVENTNATIVE_USER:$EVENTNATIVE_USER /home/$EVENTNATIVE_USER/app
ADD server/entrypoint.sh /home/$EVENTNATIVE_USER/entrypoint.sh
RUN chmod +x /home/$EVENTNATIVE_USER/entrypoint.sh
USER $EVENTNATIVE_USER
VOLUME ["/home/$EVENTNATIVE_USER/data"]
EXPOSE 8001
SHELL ["/bin/bash","-c"]
ENTRYPOINT /home/$EVENTNATIVE_USER/entrypoint.sh