forked from teamatldocker/bitbucket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
100 lines (93 loc) · 4.29 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
FROM adoptopenjdk/openjdk11:jre-11.0.11_9-alpine
MAINTAINER Steffen Bleul <sbl@blacklabelops.com>
ARG BITBUCKET_VERSION=8.11.0
# permissions
ARG CONTAINER_UID=1000
ARG CONTAINER_GID=1000
ENV BITBUCKET_HOME=/var/atlassian/bitbucket \
BITBUCKET_INSTALL=/opt/bitbucket \
BITBUCKET_PROXY_NAME= \
BITBUCKET_PROXY_PORT= \
BITBUCKET_PROXY_SCHEME= \
BITBUCKET_BACKUP_CLIENT=/opt/backupclient/bitbucket-backup-client \
BITBUCKET_BACKUP_CLIENT_HOME=/opt/backupclient \
BITBUCKET_BACKUP_CLIENT_VERSION=400000000 \
KEYSTORE=$JAVA_HOME/lib/security/cacerts
RUN export CONTAINER_USER=bitbucket && \
export CONTAINER_GROUP=bitbucket && \
addgroup --gid $CONTAINER_GID $CONTAINER_GROUP && \
adduser -u $CONTAINER_UID \
-g $CONTAINER_GROUP \
-h /home/$CONTAINER_USER \
-s /bin/bash \
-S $CONTAINER_USER && \
apk add --update \
bash \
ca-certificates \
gzip \
curl \
openssh \
util-linux \
git \
perl \
wget \
sudo \
ttf-dejavu \
git-daemon \
tini \
xmlstarlet && \
wget -O /tmp/bitbucket.tar.gz https://www.atlassian.com/software/stash/downloads/binary/atlassian-bitbucket-${BITBUCKET_VERSION}.tar.gz && \
tar zxf /tmp/bitbucket.tar.gz -C /tmp && \
mv /tmp/atlassian-bitbucket-${BITBUCKET_VERSION} /tmp/bitbucket && \
mkdir -p ${BITBUCKET_HOME} && \
mkdir -p /opt && \
mv /tmp/bitbucket /opt/bitbucket && \
export KEYSTORE=${KEYSTORE} && \
chmod 644 ${KEYSTORE} && \
# Adding letsencrypt-ca to truststore
wget -P /tmp/ https://letsencrypt.org/certs/lets-encrypt-x1-cross-signed.der && \
wget -P /tmp/ https://letsencrypt.org/certs/lets-encrypt-x2-cross-signed.der && \
wget -P /tmp/ https://letsencrypt.org/certs/lets-encrypt-x3-cross-signed.der && \
wget -P /tmp/ https://letsencrypt.org/certs/lets-encrypt-x4-cross-signed.der && \
keytool -trustcacerts -keystore $KEYSTORE -storepass changeit -noprompt -importcert -alias letsencryptauthorityx1 -file /tmp/lets-encrypt-x1-cross-signed.der && \
keytool -trustcacerts -keystore $KEYSTORE -storepass changeit -noprompt -importcert -alias letsencryptauthorityx2 -file /tmp/lets-encrypt-x2-cross-signed.der && \
keytool -trustcacerts -keystore $KEYSTORE -storepass changeit -noprompt -importcert -alias letsencryptauthorityx3 -file /tmp/lets-encrypt-x3-cross-signed.der && \
keytool -trustcacerts -keystore $KEYSTORE -storepass changeit -noprompt -importcert -alias letsencryptauthorityx4 -file /tmp/lets-encrypt-x4-cross-signed.der && \
# Install atlassian ssl tool
wget -O /home/${CONTAINER_USER}/SSLPoke.class https://confluence.atlassian.com/kb/files/779355358/779355357/1/1441897666313/SSLPoke.class && \
# Prepare cert import directory \
mkdir ${BITBUCKET_HOME}/certs && \
# Container user permissions
chown -R bitbucket:bitbucket /home/${CONTAINER_USER} && \
chown -R bitbucket:bitbucket ${BITBUCKET_HOME} && \
chown -R bitbucket:bitbucket ${BITBUCKET_INSTALL} && \
chown bitbucket:bitbucket ${KEYSTORE}
RUN mkdir -p ${BITBUCKET_BACKUP_CLIENT_HOME} && \
wget -O /tmp/bitbucket-backup-distribution.zip \
--local-encoding=utf-8 \
https://marketplace.atlassian.com/download/plugins/com.atlassian.stash.backup.client/version/${BITBUCKET_BACKUP_CLIENT_VERSION} && \
unzip -d ${BITBUCKET_BACKUP_CLIENT_HOME} /tmp/bitbucket-backup-distribution.zip && \
mv /opt/backupclient/$(ls /opt/backupclient/) /opt/backupclient/bitbucket-backup-client && \
chown -R bitbucket:bitbucket ${BITBUCKET_BACKUP_CLIENT_HOME}
RUN echo "bitbucket ALL=(ALL) NOPASSWD: /sbin/route" >> /etc/sudoers
# Remove obsolete packages
RUN apk del \
ca-certificates \
gzip \
util-linux \
wget && \
# Clean caches and tmps
rm -rf /var/cache/apk/* && \
rm -rf /tmp/* && \
rm -rf /var/log/*
USER bitbucket
WORKDIR /var/atlassian/bitbucket
VOLUME ["/var/atlassian/bitbucket"]
EXPOSE 7990 7990
EXPOSE 7999 7999
EXPOSE 7992 7992
COPY imagescripts/docker-entrypoint.sh /home/bitbucket/
COPY imagescripts/ps_opt_p_enabled_for_alpine.sh /usr/bin/ps
COPY imagescripts/dockerwait.sh /usr/bin/dockerwait
ENTRYPOINT ["/sbin/tini","--","/home/bitbucket/docker-entrypoint.sh"]
CMD ["bitbucket"]