forked from dasch-swiss/sipi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
159 lines (121 loc) · 4.27 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
# syntax=docker/dockerfile:1.3
# Expose (global) variables (ARGs before FROM can only be used on FROM lines and not afterwards)
ARG BUILD_TYPE=production
ARG SIPI_BASE=daschswiss/sipi-base:2.6.0
ARG UBUNTU_BASE=ubuntu:20.04
# STAGE 1: Build debug
FROM $SIPI_BASE as builder-debug
WORKDIR /sipi
# Add everything to image.
COPY . .
# set ccache directory
ENV CCACHE_DIR=/ccache
# Build SIPI.
RUN --mount=type=cache,target=/ccache \
mkdir -p /sipi/build-linux && \
cd /sipi/build-linux && \
cmake -DMAKE_DEBUG:BOOL=ON .. && \
make
# STAGE 1: Build production
FROM $SIPI_BASE as builder-production
WORKDIR /sipi
# Add everything to image.
COPY . .
# set ccache directory
ENV CCACHE_DIR=/ccache
# Build SIPI.
RUN --mount=type=cache,target=/ccache \
mkdir -p /sipi/build-linux && \
cd /sipi/build-linux && \
cmake -DMAKE_DEBUG:BOOL=OFF .. && \
make
# STAGE 2: Setup debug
FROM $UBUNTU_BASE as debug
LABEL maintainer="[email protected]"
# Silence debconf messages
ARG DEBIAN_FRONTEND=noninteractive
# needs to be separate because of gnupg2 which is needed for the keyserver stuff
RUN sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && \
apt-get update && apt-get -y install \
ca-certificates \
gnupg2
# Install build dependencies.
RUN sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && \
echo 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-11 main' | tee -a /etc/apt/sources.list && \
echo 'deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-11 main' | tee -a /etc/apt/sources.list && \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 15CF4D18AF4F7421 && \
apt-get update && apt-get -y install \
byobu curl git htop man vim wget unzip \
libllvm11 llvm-11-runtime \
openssl \
libidn11-dev \
locales \
uuid \
ffmpeg \
at \
bc \
imagemagick \
valgrind
# add locales
RUN locale-gen en_US.UTF-8 && \
locale-gen sr_RS.UTF-8
ENV LC_ALL=en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US.UTF-8
WORKDIR /sipi
EXPOSE 1024
RUN mkdir -p /sipi/images/knora && \
mkdir -p /sipi/cache
# Copy Sipi binary and other files from the build stage
COPY --from=builder-debug /sipi/build-linux/sipi /sipi/sipi
COPY --from=builder-debug /sipi/config/sipi.config.lua /sipi/config/sipi.config.lua
COPY --from=builder-debug /sipi/config/sipi.init.lua /sipi/config/sipi.init.lua
COPY --from=builder-debug /sipi/server/test.html /sipi/server/test.html
ENTRYPOINT [ "/sipi/sipi" ]
CMD ["--config=/sipi/config/sipi.config.lua"]
# STAGE 2: Setup production
FROM $UBUNTU_BASE as production
LABEL maintainer="[email protected]"
# Silence debconf messages
ARG DEBIAN_FRONTEND=noninteractive
# needs to be separate because of gnupg2 which is needed for the keyserver stuff
RUN sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && \
apt-get update && apt-get -y install \
ca-certificates \
gnupg2
# Install build dependencies.
RUN sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && \
echo 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-11 main' | tee -a /etc/apt/sources.list && \
echo 'deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-11 main' | tee -a /etc/apt/sources.list && \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 15CF4D18AF4F7421 && \
apt-get update && apt-get -y install \
byobu curl git htop man vim wget unzip \
libllvm11 llvm-11-runtime \
openssl \
libidn11-dev \
locales \
uuid \
ffmpeg \
at \
bc \
imagemagick
# add locales
RUN locale-gen en_US.UTF-8 && \
locale-gen sr_RS.UTF-8
ENV LC_ALL=en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US.UTF-8
WORKDIR /sipi
EXPOSE 1024
RUN mkdir -p /sipi/images/knora && \
mkdir -p /sipi/cache
# Copy Sipi binary and other files from the build stage
COPY --from=builder-production /sipi/build-linux/sipi /sipi/sipi
COPY --from=builder-production /sipi/config/sipi.config.lua /sipi/config/sipi.config.lua
COPY --from=builder-production /sipi/config/sipi.init.lua /sipi/config/sipi.init.lua
COPY --from=builder-production /sipi/server/test.html /sipi/server/test.html
ENTRYPOINT [ "/sipi/sipi" ]
CMD ["--config=/sipi/config/sipi.config.lua"]
#
# Stage 3: The final build type specific image
FROM $BUILD_TYPE