-
Notifications
You must be signed in to change notification settings - Fork 31
/
Dockerfile
161 lines (138 loc) · 7.09 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
#
# Copyright 2019-2020 JetBrains s.r.o.
#
# Licensed 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.
#
# Modify by [email protected]
# Base on JetBrains Projector (https://github.com/JetBrains/projector-server)
FROM icyfenix/openjdk-build-environment:jdk15 AS jdkRepo
ENV JDK_DIR /home/projector-user/jdk
ADD jdk-source $JDK_DIR
WORKDIR $JDK_DIR
RUN true \
# Any command which returns non-zero exit code will cause this shell script to exit immediately:
&& set -e \
# Activate debugging to show execution details: all commands will be printed before execution
&& set -x \
# Make configuration for linux-x86-slowdebug:
&& chmod +x ./configure \
&& ./configure --with-boot-jdk=/usr/lib/jvm/openjdk-15-jdk --with-debug-level=slowdebug --disable-warnings-as-errors --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --with-version-opt=icyfenix.cn\
# Make compilation database:
&& make make compile-commands \
# Copy compile_commands.json to the root of this project
&& cp $JDK_DIR/build/linux-x86_64-server-slowdebug/compile_commands.json $JDK_DIR
FROM debian AS ideDownloader
# prepare tools:
RUN apt-get update
RUN apt-get install wget -y
# download IDE to the /ide dir:
WORKDIR /download
ARG downloadUrl
RUN wget -q $downloadUrl -O - | tar -xz
RUN find . -maxdepth 1 -type d -name * -execdir mv {} /ide \;
FROM amazoncorretto:11 as projectorGradleBuilder
ENV PROJECTOR_DIR /projector
# projector-server:
ADD projector-server $PROJECTOR_DIR/projector-server
WORKDIR $PROJECTOR_DIR/projector-server
ARG buildGradle
RUN if [ "$buildGradle" = "true" ]; then ./gradlew clean; else echo "Skipping gradle build"; fi
RUN if [ "$buildGradle" = "true" ]; then ./gradlew :projector-server:distZip; else echo "Skipping gradle build"; fi
FROM debian AS projectorStaticFiles
# prepare tools:
RUN apt-get update
RUN apt-get install unzip -y
# create the Projector dir:
ENV PROJECTOR_DIR /projector
RUN mkdir -p $PROJECTOR_DIR
# copy IDE:
COPY --from=ideDownloader /ide $PROJECTOR_DIR/ide
# copy projector files to the container:
ADD openjdk-for-dummies/static $PROJECTOR_DIR
# copy projector:
COPY --from=projectorGradleBuilder $PROJECTOR_DIR/projector-server/projector-server/build/distributions/projector-server-1.0-SNAPSHOT.zip $PROJECTOR_DIR
# prepare IDE - apply projector-server:
RUN unzip $PROJECTOR_DIR/projector-server-1.0-SNAPSHOT.zip
RUN rm $PROJECTOR_DIR/projector-server-1.0-SNAPSHOT.zip
RUN mv projector-server-1.0-SNAPSHOT $PROJECTOR_DIR/ide/projector-server
RUN mv $PROJECTOR_DIR/ide-projector-launcher.sh $PROJECTOR_DIR/ide/bin
RUN chmod 644 $PROJECTOR_DIR/ide/projector-server/lib/*
FROM debian:10
RUN true \
# Any command which returns non-zero exit code will cause this shell script to exit immediately:
&& set -e \
# Activate debugging to show execution details: all commands will be printed before execution
&& set -x \
# install packages:
&& apt-get update \
# packages for awt:
&& apt-get install libxext6 libxrender1 libxtst6 libxi6 libfreetype6 -y \
# packages for user convenience:
&& apt-get install git bash-completion -y \
# packages for IDEA (to disable warnings):
&& apt-get install procps -y \
# clean apt to reduce image size:
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /var/cache/apt
ARG downloadUrl
RUN true \
# Any command which returns non-zero exit code will cause this shell script to exit immediately:
&& set -e \
# Activate debugging to show execution details: all commands will be printed before execution
&& set -x \
# install specific packages for IDEs:
&& apt-get update \
&& if [ "${downloadUrl#*CLion}" != "$downloadUrl" ]; then apt-get install build-essential clang libxt-dev zip pkg-config libx11-dev libxext-dev build-essential autoconf file libxrandr-dev libfontconfig1-dev libxrender-dev libxtst-dev libasound2-dev libcups2-dev libfreetype6-dev -y; else echo "Not CLion"; fi \
&& if [ "${downloadUrl#*pycharm}" != "$downloadUrl" ]; then apt-get install python2 python3 python3-distutils python3-pip python3-setuptools -y; else echo "Not pycharm"; fi \
&& if [ "${downloadUrl#*rider}" != "$downloadUrl" ]; then apt install apt-transport-https dirmngr gnupg ca-certificates -y && apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF && echo "deb https://download.mono-project.com/repo/debian stable-buster main" | tee /etc/apt/sources.list.d/mono-official-stable.list && apt update && apt install mono-devel -y && apt install wget -y && wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && dpkg -i packages-microsoft-prod.deb && rm packages-microsoft-prod.deb && apt-get update && apt-get install -y apt-transport-https && apt-get update && apt-get install -y dotnet-sdk-3.1 aspnetcore-runtime-3.1; else echo "Not rider"; fi \
# clean apt to reduce image size:
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /var/cache/apt
# copy the Projector dir:
ENV PROJECTOR_DIR /projector
COPY --from=projectorStaticFiles $PROJECTOR_DIR $PROJECTOR_DIR
ENV PROJECTOR_USER_NAME projector-user
RUN true \
# Any command which returns non-zero exit code will cause this shell script to exit immediately:
&& set -e \
# Activate debugging to show execution details: all commands will be printed before execution
&& set -x \
# move run scipt:
&& mv $PROJECTOR_DIR/run.sh run.sh \
# change user to non-root (http://pjdietz.com/2016/08/28/nginx-in-docker-without-root.html):
&& mv $PROJECTOR_DIR/$PROJECTOR_USER_NAME /home \
&& useradd -m -d /home/$PROJECTOR_USER_NAME -s /bin/bash $PROJECTOR_USER_NAME \
&& chown -R $PROJECTOR_USER_NAME.$PROJECTOR_USER_NAME /home/$PROJECTOR_USER_NAME \
&& chown -R $PROJECTOR_USER_NAME.$PROJECTOR_USER_NAME $PROJECTOR_DIR/ide/bin \
&& chown $PROJECTOR_USER_NAME.$PROJECTOR_USER_NAME run.sh \
&& chmod +x run.sh \
&& chmod +x $PROJECTOR_DIR/ide/bin/ide-projector-launcher.sh
ENV JDK_DIR /home/projector-user/jdk
ENV BOOT_JDK_DIR /usr/lib/jvm/openjdk-15-jdk
COPY --from=jdkRepo $JDK_DIR $JDK_DIR
COPY --from=jdkRepo $BOOT_JDK_DIR $BOOT_JDK_DIR
ENV HOME /home/$PROJECTOR_USER_NAME
ENV JAVA_HOME /home/$PROJECTOR_USER_NAME
RUN true \
# Any command which returns non-zero exit code will cause this shell script to exit immediately:
&& set -e \
# Activate debugging to show execution details: all commands will be printed before execution
&& set -x \
# Move default java playground to home
&& mv $PROJECTOR_DIR/playground $HOME \
# Move jdk clion projector to root dir
&& mv $PROJECTOR_DIR/jdk-project $JDK_DIR/.idea \
# Set JDK src writable for non-root
&& chmod o+w -R $JDK_DIR
USER $PROJECTOR_USER_NAME
CMD ["bash", "-c", "/run.sh"]