##// END OF EJS Templates
docker: added source installation, dev scripts and mysql config
marcink -
r5:e1b5e0f3
parent child Browse files
Show More
1 NO CONTENT: new file 100644
@@ -0,0 +1,63 b''
1 #!/usr/bin/env bash
2 set -euo pipefail
3 IFS=$'\n\t'
4 CURRENT_USER_UID=$(id -u)
5 CURRENT_USER_GID=$(id -g)
6 USER_UID=${USER_UID:-$CURRENT_USER_UID}
7 USER_GID=${USER_GID:-$CURRENT_USER_GID}
8 CMD="docker-compose -f docker-compose.yml"
9 BUILD_CMD="docker-compose -f docker-compose.yaml -f docker-compose.source.yml"
10 DEV_CMD="docker-compose -f docker-compose.yaml -f docker-compose.source.yml -f docker-compose.dev.yml"
11
12 usage="$(basename "$0") ./dev.sh <COMMAND> -- run docker command
13 where <COMMAND>:
14 [v]cs -- run bash console for vcsserver
15 [r]c -- run bash console for rhodecode-ee
16 ce -- run bash console for rhodecode-ce
17 [t]est[s] -- run bash console for rhodecode-ce tests
18 test-mysql -- run bash console for rhodecode-ce tests with mysql
19 test-pgsql -- run bash console for rhodecode-ce tests with postgres
20 dev-build -- build rhodecode dev app for use without cache use
21 dev-env -- run the dev stack required for development
22 redis -- run the redis CLI attached to rc_cluster_redis_1
23 run <cmd> -- run <cmd>"
24
25 case ${1:-} in
26 v|vcs )
27 eval "(docker stop vcsserver-dev || echo skip-stop ) && ${DEV_CMD} run --service-ports --rm --use-aliases --workdir="/home/rhodecode/rhodecode-vcsserver" --name="vcsserver-dev" vcsserver bash"
28 exit
29 ;;
30 r|rc )
31 eval "(docker stop enterprise-ee-dev || echo skip-stop ) && ${DEV_CMD} run --publish 8080:8080 --rm --use-aliases --workdir="/home/rhodecode/rhodecode-enterprise-ee" --name="enterprise-ee-dev" rhodecode bash"
32 exit
33 ;;
34 ce )
35 eval "(docker stop enterprise-ce-dev || echo skip-stop ) && ${DEV_CMD} run --publish 8081:8080 --rm --use-aliases --workdir="/home/rhodecode/rhodecode-enterprise-ce" --name="enterprise-ce-dev" rhodecode bash"
36 exit
37 ;;
38 t|test|tests )
39 eval "${DEV_CMD} run --rm --use-aliases --workdir="/home/rhodecode/rhodecode-enterprise-ce" --name="enterprise-dev-test" rhodecode bash"
40 exit
41 ;;
42 dev-build )
43 eval "${BUILD_CMD} up --detach database && ${BUILD_CMD} build --no-cache --progress=plain rhodecode"
44 exit
45 ;;
46 dev-env )
47 eval "${BUILD_CMD} up --detach database redis channelstream nginx celery beat"
48 exit
49 ;;
50 redis )
51 eval "docker exec --interactive --tty rc_cluster_redis_1 redis-cli"
52 exit
53 ;;
54 run )
55 command=${@:2}
56 eval "${DEV_CMD} run --rm rhodecode ${command}"
57 exit
58 ;;
59 * )
60 echo "${usage}"
61 exit
62 ;;
63 esac
@@ -0,0 +1,80 b''
1 volumes:
2 bashhistory:
3
4
5 services:
6
7 rhodecode:
8 environment:
9 HISTFILE: /home/rhodecode/.bash_history_docker
10 DB_UPGRADE: 0 # run the DB upgrade
11
12 volumes:
13 - bashhistory:/home/rhodecode
14
15 build:
16 context: .
17 dockerfile: service/rhodecode/rhodecode_source.dockerfile
18
19 image: rhodecode/app_source:latest
20
21 command: [
22 "/home/rhodecode/rhodecode-enterprise-ee/result/bin/gunicorn",
23 "--name=gunicorn-rhodecode-1",
24 "--error-logfile=-",
25 "--paster=/etc/rhodecode/conf/compose/rhodecode.optimized.ini",
26 "--config=/etc/rhodecode/conf/gunicorn_conf.py"
27 ]
28
29 vcsserver:
30 environment:
31 HISTFILE: /home/rhodecode/.bash_history_docker
32
33 volumes:
34 - bashhistory:/home/rhodecode
35
36 build:
37 context: .
38 dockerfile: service/rhodecode/rhodecode_source.dockerfile
39
40 image: rhodecode/app_source:latest
41
42 command: [
43 "/home/rhodecode/rhodecode-vcsserver/result/bin/gunicorn",
44 "--name=gunicorn-vcsserver-1",
45 "--error-logfile=-",
46 "--paster=/etc/rhodecode/conf/compose/vcsserver.optimized.ini",
47 "--config=/etc/rhodecode/conf/gunicorn_conf.py"
48 ]
49
50 celery:
51
52 build:
53 context: .
54 dockerfile: service/rhodecode/rhodecode_source.dockerfile
55
56 image: rhodecode/app_source:latest
57
58 beat:
59
60 build:
61 context: .
62 dockerfile: service/rhodecode/rhodecode_source.dockerfile
63
64 image: rhodecode/app_source:latest
65
66 svn:
67
68 build:
69 context: .
70 dockerfile: service/rhodecode/rhodecode_source.dockerfile
71
72 image: rhodecode/app_source:latest
73
74 sshd:
75
76 build:
77 context: .
78 dockerfile: service/rhodecode/rhodecode_source.dockerfile
79
80 image: rhodecode/app_source:latest No newline at end of file
@@ -0,0 +1,3 b''
1 character-set-client-handshake = FALSE
2 character-set-server = utf8mb4
3 collation-server = utf8mb4_unicode_ci
@@ -0,0 +1,5 b''
1 ARG MYSQL_BUILD
2 FROM library/mysql:$MYSQL_BUILD
3
4 RUN mkdir -p /etc/mysql/conf.d
5 COPY service/database/mysql_customized.conf /etc/mysql/conf.d/config-file.cnf
@@ -0,0 +1,298 b''
1 FROM ubuntu:groovy
2 MAINTAINER RhodeCode Inc. <support@rhodecode.com>
3
4 ARG TZ="UTC"
5 ARG LOCALE_TYPE=en_US.UTF-8
6 ARG RHODECODE_TYPE=Enterprise
7 # source-install
8 ARG RHODECODE_VERSION=4.25.0
9
10 ARG RHODECODE_DB=sqlite
11 ARG RHODECODE_USER_NAME=admin
12 ARG RHODECODE_USER_PASS=secret4
13 ARG RHODECODE_USER_EMAIL=support@rhodecode.com
14
15 # nix ver/channels
16 ARG DEV_NIX_VERSION=2.0.4
17 ARG DEV_NIX_CHANNEL=nixos-18.03
18
19 # env are runtime
20 ENV \
21 TZ=${TZ} \
22 LOCALE_TYPE=${LOCALE_TYPE} \
23 \
24 ## Define type we build, and the instance we'll create
25 RHODECODE_TYPE=${RHODECODE_TYPE} \
26 RC_TYPE_ID=enterprise-1 \
27 \
28 ## SETUP ARGS FOR INSTALLATION ##
29 ## set version we build on, get from .env or set default ver
30 RHODECODE_VERSION=${RHODECODE_VERSION} \
31 \
32 ## set DB, default sqlite
33 RHODECODE_DB=${RHODECODE_DB} \
34 \
35 ## set app bootstrap required data
36 RHODECODE_USER_NAME=${RHODECODE_USER_NAME} \
37 RHODECODE_USER_PASS=${RHODECODE_USER_PASS} \
38 RHODECODE_USER_EMAIL=${RHODECODE_USER_EMAIL} \
39 \
40 RC_USER=rhodecode \
41 \
42 # SVN CONFIG
43 MOD_DAV_SVN_CONF_FILE=/etc/rhodecode/conf/svn/mod_dav_svn.conf \
44 MOD_DAV_SVN_PORT=8090 \
45 \
46 # SSHD CONFIG
47 SSHD_CONF_FILE=/etc/rhodecode/sshd_config \
48 \
49 BUILD_CONF=/etc/rhodecode/conf_build \
50 BUILD_BIN_DIR=/var/opt/rhodecode_bin \
51 RHODECODE_DATA_DIR=/var/opt/rhodecode_data \
52 RHODECODE_REPO_DIR=/var/opt/rhodecode_repo_store \
53 RHODECODE_HTTP_PORT=10020 \
54 RHODECODE_VCS_PORT=10010 \
55 RHODECODE_HOST=0.0.0.0 \
56 RHODECODE_VCS_HOST=127.0.0.1
57
58 ENV \
59 RCCONTROL=/home/$RC_USER/.rccontrol-profile/bin/rccontrol \
60 SUPERVISOR_CONF=/home/$RC_USER/.rccontrol/supervisor/supervisord.ini \
61 # make application scripts visible
62 PATH=$PATH:/home/$RC_USER/.rccontrol-profile/bin
63
64 ENV SVN_LOCALE_DEPS apache2 apache2-utils libapache2-mod-svn
65 ENV SSH_LOCALE_DEPS openssh-server
66 ENV PYTHON_DEPS python2
67 ENV EXTRA_DEPS vim
68
69 ENV \
70 PATH=$PATH:/nix/var/nix/profiles/per-user/$RC_USER/profile/bin:/home/$RC_USER/rhodecode-enterprise-ee/profile/bin \
71 NIX_BLD_USER=nixbld \
72 NIX_PATH=/nix/var/nix/profiles/per-user/$RC_USER/channels
73
74 RUN \
75 echo "** install base packages **" && \
76 set -eux; \
77 \
78 savedAptMark="$(apt-mark showmanual)"; \
79 apt-get update; \
80 DEBIAN_FRONTEND="noninteractive" \
81 apt-get install -y --no-install-recommends \
82 tini \
83 bash \
84 binutils \
85 tzdata \
86 locales \
87 openssl \
88 curl \
89 sudo \
90 gosu \
91 bzip2 \
92 ca-certificates \
93 $PYTHON_DEPS \
94 $SSH_LOCALE_DEPS \
95 $SVN_LOCALE_DEPS \
96 $EXTRA_DEPS \
97 ; \
98 rm -rf /var/lib/apt/lists/*;
99
100 RUN \
101 echo "** Configure the python executable for py2/3 compat **" && \
102 ISPY=$(which python3 || which python2) && \
103 if [ -n $ISPY ] ; then ln -s $ISPY /usr/bin/python ; fi
104
105 RUN \
106 echo "** Configure the locales **" && \
107 sed -i "s/^# ${LOCALE_TYPE}/${LOCALE_TYPE}/g" /etc/locale.gen && \
108 locale-gen
109
110 # locale-archive is a fix for old nix glibc2.26 locales available
111 ENV \
112 LOCALE_ARCHIVE=/var/opt/locale-archive \
113 LANG=${LOCALE_TYPE} \
114 LANGUAGE=${LOCALE_TYPE} \
115 LC_ALL=${LOCALE_TYPE}
116
117 # configure the system user
118 # explicitly set uid/gid to guarantee that it won't change in the future
119 # the values 999:999 are identical to the current user/group id assigned
120 RUN \
121 echo "** Create system user $RC_USER **" && \
122 groupadd --system --gid 999 $RC_USER && \
123 useradd --system --gid $RC_USER --uid 999 --shell /bin/bash $RC_USER && \
124 usermod -G $RC_USER $RC_USER
125
126 RUN \
127 echo "** Create nix-build user $NIX_BLD_USER **" && \
128 groupadd --system --gid 1099 $NIX_BLD_USER && \
129 useradd --system --gid $NIX_BLD_USER --uid 1099 --shell /bin/bash $NIX_BLD_USER && \
130 usermod -G $NIX_BLD_USER $NIX_BLD_USER
131
132 RUN \
133 echo "** disable nix sandboxing **" && \
134 mkdir /etc/nix && echo 'sandbox = false' > /etc/nix/nix.conf
135
136
137 # set the defult bash shell
138 SHELL ["/bin/bash", "-c"]
139
140 # Fix and set a timezone
141 RUN \
142 echo "** configure the timezone **" && \
143 rm /etc/localtime && cp /usr/share/zoneinfo/$TZ /etc/localtime && \
144 echo $TZ > /etc/timezone
145
146
147 RUN \
148 echo "** prepare rhodecode store and cache **" && \
149 install -d -m 0700 -o $RC_USER -g $RC_USER /nix && \
150 install -d -m 0755 -o $RC_USER -g $RC_USER /opt/rhodecode && \
151 install -d -m 0755 -o $RC_USER -g $RC_USER /var/opt/rhodecode_bin && \
152 install -d -m 0755 -o $RC_USER -g $RC_USER $RHODECODE_REPO_DIR && \
153 install -d -m 0755 -o $RC_USER -g $RC_USER $RHODECODE_DATA_DIR && \
154 install -d -m 0755 -o $RC_USER -g $RC_USER $BUILD_CONF && \
155 install -d -m 0755 -o $RC_USER -g $RC_USER /home/$RC_USER/ && \
156 install -d -m 0755 -o $RC_USER -g $RC_USER /home/$RC_USER/.rccontrol && \
157 install -d -m 0755 -o $RC_USER -g $RC_USER /home/$RC_USER/.rccontrol/cache && \
158 install -d -m 0755 -o $RC_USER -g $RC_USER /home/$RC_USER/.rccontrol/bootstrap && \
159 install -d -m 0700 -o $RC_USER -g $RC_USER /home/$RC_USER/.ssh
160
161 # expose our custom sshd config
162 COPY service/sshd/sshd_config $SSHD_CONF_FILE
163
164 # Apache SVN setup
165 RUN \
166 echo "**** Apache config cleanup ****" && \
167 rm -f /etc/apache2/conf.d/info.conf \
168 /etc/apache2/conf.d/mpm.conf \
169 /etc/apache2/conf.d/userdir.conf && \
170 rm -f /etc/apache2/sites-enabled/* && \
171 rm -f /etc/apache2/sites-available/*
172
173 # custom SVN virtualhost
174 COPY service/svn/virtualhost.conf /etc/apache2/sites-enabled/
175
176 RUN \
177 echo "**** Apache config ****" && \
178 echo $(strings /usr/lib/apache2/modules/mod_dav_svn.so | grep 'Powered by') > /var/opt/dav.version && \
179 mkdir -p /run/apache2 && \
180 mkdir -p /var/opt/www && \
181 echo "unset HOME" > /etc/apache2/envvars && \
182 echo "export APACHE_RUN_USER=${RC_USER}" >> /etc/apache2/envvars && \
183 echo "export APACHE_PID_FILE=/var/run/apache2/apache2.pid" >> /etc/apache2/envvars && \
184 echo "export APACHE_RUN_DIR=/var/run/apache2" >> /etc/apache2/envvars && \
185 echo "export APACHE_LOCK_DIR=/var/lock/apache2" >> /etc/apache2/envvars && \
186 echo "export APACHE_RUN_USER=${RC_USER}" >> /etc/apache2/envvars && \
187 echo "export APACHE_RUN_GROUP=${RC_USER}" >> /etc/apache2/envvars && \
188 sed -i "s/Listen 80/Listen ${MOD_DAV_SVN_PORT}/g" /etc/apache2/ports.conf
189
190
191 # Copy artifacts
192 COPY --chown=$RC_USER:$RC_USER .source/ /home/$RC_USER/
193 COPY --chown=$RC_USER:$RC_USER .cache/* /home/$RC_USER/.rccontrol/cache/
194 COPY --chown=$RC_USER:$RC_USER config/compose/rhodecode_enterprise.license /home/$RC_USER/.rccontrol/bootstrap/
195 COPY --chown=$RC_USER:$RC_USER service/rhodecode/bootstrap/* /home/$RC_USER/.rccontrol/bootstrap/
196
197 RUN \
198 echo "**** locale-archive path ****" && \
199 mv -v /home/$RC_USER/.rccontrol/cache/locale-archive /var/opt/locale-archive
200
201 # change to non-root user for RUN commands
202 USER $RC_USER
203 WORKDIR /home/$RC_USER
204
205 RUN \
206 echo "** download and install nix **" && \
207 curl -L https://releases.nixos.org/nix/nix-$DEV_NIX_VERSION/install | USER=$RC_USER /bin/bash
208
209 RUN \
210 echo "** update nix package database and set channel to $DEV_NIX_CHANNEL **" && \
211 . /home/rhodecode/.nix-profile/etc/profile.d/nix.sh && \
212 nix-channel --add https://nixos.org/channels/$DEV_NIX_CHANNEL nixpkgs && \
213 nix-channel --update
214
215
216 RUN \
217 echo "** save nix config **" && \
218 touch /home/$RC_USER/.rhoderc && \
219 mkdir -p /home/$RC_USER/.nixpkgs && touch /home/$RC_USER/.nixpkgs/config.nix && \
220 printf '{\n rc = {\n sources = {\n rhodecode-vcsserver = "/home/'$RC_USER'/rhodecode-vcsserver";\n rhodecode-enterprise-ce = "/home/'$RC_USER'/rhodecode-enterprise-ce";\n rhodecode-enterprise-ee = "/home/'$RC_USER'/rhodecode-enterprise-ee";\n };\n };\n}\n' > /home/$RC_USER/.nixpkgs/config.nix
221
222
223 RUN \
224 echo "** install rhodecode control **" && \
225 # cd /home/$RC_USER/.rccontrol/cache && \
226 # INSTALLER=$(ls -Art /home/$RC_USER/.rccontrol/cache/RhodeCode-installer-* | tail -n 1) && \
227 # chmod +x ${INSTALLER} && \
228 # ${INSTALLER} --accept-license && \
229 # ${RCCONTROL} self-init && \
230 # cp -v /home/$RC_USER/.rccontrol-profile/etc/ca-bundle.crt $BUILD_CONF/ && \
231 echo "Done"
232
233 RUN \
234 echo "** install build vcsserver ${RHODECODE_VERSION} **" && \
235 . /home/rhodecode/.nix-profile/etc/profile.d/nix.sh && \
236 nix-build --show-trace --cores 0 --max-jobs 4 --no-build-output --out-link rhodecode-vcsserver/result rhodecode-vcsserver/default.nix && \
237 nix-shell --command 'echo ok' rhodecode-vcsserver/default.nix && \
238 VCSSERVER_PATH=/home/$RC_USER/rhodecode-vcsserver && \
239 rm -rf $BUILD_BIN_DIR/vcs_bin && ln -s ${VCSSERVER_PATH}/result/bin $BUILD_BIN_DIR/vcs_bin && \
240 cp -v ${VCSSERVER_PATH}/configs/production.ini $BUILD_CONF/vcsserver.ini
241
242 RUN \
243 echo "** install build Community ${RHODECODE_VERSION} **" && \
244 . /home/rhodecode/.nix-profile/etc/profile.d/nix.sh && \
245 echo "done"
246
247 RUN \
248 echo "** install build Enterprise ${RHODECODE_VERSION} **" && \
249 . /home/rhodecode/.nix-profile/etc/profile.d/nix.sh && \
250 nix-build --show-trace --cores 0 --max-jobs 4 --no-build-output --out-link rhodecode-enterprise-ee/result rhodecode-enterprise-ee/default.nix && \
251 nix-shell --command 'echo ok' rhodecode-enterprise-ee/default.nix && \
252 RHODECODE_PATH=/home/$RC_USER/rhodecode-enterprise-ee && \
253 rm -rf $BUILD_BIN_DIR/bin && ln -s ${RHODECODE_PATH}/result/bin $BUILD_BIN_DIR/ && \
254 cp -v ${RHODECODE_PATH}/configs/production.ini $BUILD_CONF/rhodecode.ini && \
255 cp -v ${RHODECODE_PATH}/configs/gunicorn_config.py $BUILD_CONF/gunicorn_conf.py && \
256 mkdir -p $RHODECODE_DATA_DIR/static && cp -r ${RHODECODE_PATH}/result/etc/static/* $RHODECODE_DATA_DIR/static/
257
258
259 RUN \
260 echo "** configure supervisord **" && \
261 #cp -v ${SUPERVISOR_CONF} $BUILD_CONF/ && \
262 #sed -i "s/self_managed_supervisor = False/self_managed_supervisor = True/g" /home/$RC_USER/.rccontrol.ini && \
263 echo "done"
264
265 USER root
266
267
268 RUN \
269 echo "**** cleanup ****" && \
270 apt-get remove -y $PYTHON_DEPS && \
271 apt-get autoclean -y && \
272 rm -f /tmp/* && \
273 rm -f /home/$RC_USER/.rccontrol/cache/RhodeCode-installer-* && \
274 rm -f /home/$RC_USER/.rccontrol/cache/*.bz2 && \
275 rm -rf /var/lib/apt/lists/* \
276 rm -rf /var/cache/apk/* \
277 rm ${SUPERVISOR_CONF}
278
279 # copy entrypoints
280 COPY entrypoints.d/entrypoint.sh /opt/entrypoints.d/entrypoint.sh
281 RUN chmod +x /opt/entrypoints.d/entrypoint.sh
282
283 # config volume
284 VOLUME /etc/rhodecode/conf
285
286 # repo store volume
287 VOLUME /var/opt/rhodecode_repo_store
288
289 # data volume
290 VOLUME /var/opt/rhodecode_data
291
292 # logs volume
293 VOLUME /var/log/rhodecode
294
295 ENTRYPOINT ["/opt/entrypoints.d/entrypoint.sh"]
296
297 # compose can override this
298 CMD ["supervisord", "--nodaemon", "-c", "/etc/rhodecode/conf/supervisord.ini"]
General Comments 0
You need to be logged in to leave comments. Login now