forked from apache/incubator-devlake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
183 lines (148 loc) · 6.18 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
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.
#
#Apache DevLake is an effort undergoing incubation at The Apache Software
#Foundation (ASF), sponsored by the Apache Incubator PMC.
#
#Incubation is required of all newly accepted projects until a further review
#indicates that the infrastructure, communications, and decision making process
#have stabilized in a manner consistent with other successful ASF projects.
#
#While incubation status is not necessarily a reflection of the completeness or stability of the code,
#it does indicate that the project has yet to be fully endorsed by the ASF.
FROM --platform=linux/amd64 debian:bullseye as debian-amd64
RUN apt-get update
RUN apt-get install -y libssh2-1-dev libssl-dev zlib1g-dev
FROM --platform=linux/arm64 debian:bullseye as debian-arm64
RUN apt-get update
RUN apt-get install -y libssh2-1-dev libssl-dev zlib1g-dev
FROM --platform=$BUILDPLATFORM golang:1.20.4-bullseye as builder
# docker build --build-arg GOPROXY=https://goproxy.io,direct -t mericodev/lake .
ARG GOPROXY=
# docker build --build-arg HTTPS_PROXY=http://localhost:4780 -t mericodev/lake .
ARG HTTP_PROXY=
ARG HTTPS_PROXY=
RUN apt-get update
RUN apt-get install -y gcc binutils libfindbin-libs-perl cmake libssh2-1-dev libssl-dev zlib1g-dev
RUN if [ "$(arch)" != "aarch64" ] ; then \
apt-get install -y gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu ; \
fi
RUN if [ "$(arch)" != "x86_64" ] ; then \
apt-get install -y gcc-x86-64-linux-gnu binutils-x86-64-linux-gnu ; \
fi
RUN go install github.com/vektra/mockery/v2@v2.14.0
RUN go install github.com/swaggo/swag/cmd/swag@v1.8.12
COPY --from=debian-amd64 /usr/include /rootfs-amd64/usr/include
COPY --from=debian-amd64 /usr/lib/x86_64-linux-gnu /rootfs-amd64/usr/lib/x86_64-linux-gnu
COPY --from=debian-amd64 /lib/x86_64-linux-gnu /rootfs-amd64/lib/x86_64-linux-gnu
COPY --from=debian-arm64 /usr/include /rootfs-arm64/usr/include
COPY --from=debian-arm64 /usr/lib/aarch64-linux-gnu /rootfs-arm64/usr/lib/aarch64-linux-gnu
COPY --from=debian-arm64 /lib/aarch64-linux-gnu /rootfs-arm64/lib/aarch64-linux-gnu
RUN for arch in aarch64 x86_64 ; do \
mkdir -p /tmp/build/${arch} && cd /tmp/build/${arch} && \
wget https://github.com/libgit2/libgit2/archive/refs/tags/v1.3.2.tar.gz -O - | tar -xz && \
cd libgit2-1.3.2 && \
mkdir build && cd build && \
if [ "$arch" = "aarch64" ] ; then \
cmake .. -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
-DBUILD_SHARED_LIBS=ON -DCMAKE_SYSROOT=/rootfs-arm64 \
-DCMAKE_INSTALL_PREFIX=/usr/local/deps/${arch} ; \
elif [ "$arch" = "x86_64" ] ; then \
cmake .. -DCMAKE_C_COMPILER=x86_64-linux-gnu-gcc \
-DBUILD_SHARED_LIBS=ON -DCMAKE_SYSROOT=/rootfs-amd64 \
-DCMAKE_INSTALL_PREFIX=/usr/local/deps/${arch} ; \
fi && \
make -j install ; \
done
FROM builder as build
WORKDIR /app
COPY . /app
ENV GOBIN=/app/bin
ARG TARGETPLATFORM
ARG TAG=
ARG SHA=
ARG GO_PLUGINS=
ARG DEBUG=
RUN --mount=type=cache,target=/root/.cache/go-build \
if [ "$TARGETPLATFORM" = "linux/arm64" ] ; then \
ln -s /usr/local/deps/aarch64 /usr/local/deps/target && \
export CC=aarch64-linux-gnu-gcc && \
export GOARCH=arm64 ; \
else \
ln -s /usr/local/deps/x86_64 /usr/local/deps/target && \
export CC=x86_64-linux-gnu-gcc && \
export GOARCH=amd64 ; \
fi && \
export PKG_CONFIG_PATH=/usr/local/deps/target/lib/pkgconfig && \
export CGO_ENABLED=1 &&\
PLUGIN="$GO_PLUGINS" make all
RUN if [ "$DEBUG" = "true" ]; then \
go install github.com/go-delve/delve/cmd/dlv@latest; \
fi;
# remove symlink in lib, we will recreate in final image
RUN cd /usr/local/deps/target/lib && \
for file in *.so* ; do \
if [ -L $file ] ; then \
unlink $file ; \
fi \
done
FROM python:3.9-slim-bullseye as base
RUN apt-get update && \
apt-get install -y python3-dev python3-pip tar curl libssh2-1 zlib1g libffi-dev default-libmysqlclient-dev libpq-dev tini && \
apt-get clean && \
rm -fr /usr/share/doc/* \
/usr/share/info/* \
/usr/share/linda/* \
/usr/share/lintian/overrides/* \
/usr/share/locale/* \
/usr/share/man/* \
/usr/share/doc/kde/HTML/* \
/usr/share/gnome/help/* \
/usr/share/locale/* \
/usr/share/omf/*/*-*.emf \
/var/lib/apt/lists/*
EXPOSE 8080
RUN useradd -ms /bin/bash -d /app devlake -u 1010
USER devlake
ENV PYTHONUNBUFFERED=1
WORKDIR /app
RUN mkdir logs
VOLUME /app/logs
# Setup Python
COPY python/ /app/python/
RUN python3 -m pip install --no-cache --upgrade pip setuptools && \
python3 -m pip install --no-cache -r python/requirements.txt
# Setup Python Poetry package manager
RUN curl -sSL https://install.python-poetry.org | python3 -
ENV PATH="$PATH:/app/.local/bin"
# Build Python plugins, make sure the scripts has execute permission
# RUN find /app/python/ -name "*.sh" | xargs -I{} chmod +x {}
RUN /app/python/build.sh
FROM base as devlake-base
ARG DEBUG=
# libraries
ENV LD_LIBRARY_PATH=/app/libs
RUN mkdir -p /app/libs
COPY --from=build /usr/local/deps/target/lib/*.so* /app/libs
COPY --from=build /go/bin /usr/bin
RUN ldconfig -vn /app/libs
# apps
COPY --from=build /app/bin /app/bin
COPY --from=build /app/resources /app/resources
ENV PATH="/app/bin:${PATH}"
ENV DEBUG="$DEBUG"
#add tini, prevent zombie process
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["lake"]