Skip to content
This repository was archived by the owner on Aug 25, 2019. It is now read-only.

Commit 19d6435

Browse files
committed
Rewrite startup process to improve Let's Encrypt issuance and startup time
1 parent 2440f28 commit 19d6435

33 files changed

+385
-221
lines changed

15-https

-103
This file was deleted.

20-postfix

-8
This file was deleted.

25-nginx

-24
This file was deleted.

25-php-fpm

-10
This file was deleted.

50-cronie

-6
This file was deleted.

ADVANCED-CONFIG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ You can bake the configuration and initial start-up of this image into your own
6767
To bake an image, create a `Dockerfile` like this:
6868

6969
```
70-
FROM hachque/phabricator
70+
FROM redpointgames/phabricator
7171
7272
ADD my-script /my-script
7373
RUN /my-script

DOCKER-COMPOSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Docker Compose configuration file supplied in this repository defines a Phabricator service and a MySQL service.
44

5-
The MySQL service uses official MySQL Docker image mysql:5.7.14 and the Phabricator service uses image hachque/phabricator.
5+
The MySQL service uses official MySQL Docker image mysql:5.7.14 and the Phabricator service uses image redpointgames/phabricator.
66

77

88
## Configure `PHABRICATOR_HOST`

Dockerfile

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
FROM hachque/systemd-none
22

33
EXPOSE 80 443 22 24
4-
ADD nginx.conf server-http.conf server-https-letsencrypt.conf server-https-manual.conf fastcgi.conf 15-https 25-nginx 25-php-fpm 20-postfix 10-boot-conf 35-phd 40-aphlict 50-cronie 60-iomonitor php-fpm.conf php.ini setup.sh sshd_config.phabricator 45-phabricator-ssh phabricator-ssh-hook.sh bake iomonitor /preflight/
4+
COPY baseline /baseline
5+
RUN /baseline/setup.sh
6+
COPY preflight /preflight
57
RUN /preflight/setup.sh
6-
CMD ["/init"]
8+
CMD ["/bin/bash", "/app/init.sh"]

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ docker run \
1515
--env MYSQL_PASS=pass \
1616
--env PHABRICATOR_REPOSITORY_PATH=/repos \
1717
-v /host/repo/path:/repos \
18-
hachque/phabricator
18+
redpointgames/phabricator
1919
```
2020

2121
Alternatively you can launch this image with Docker Compose. Refer to [Using Docker Compose](./DOCKER-COMPOSE.md) for more information.
2222

23+
**NOTICE:** This repository has been recently moved to `RedpointGames/phabricator` and the Docker image to use is now `redpointgames/phabricator`. `hachque/phabricator` will be kept in sync with `redpointgames/phabricator` for the foreseeable future, so you don't need to update your configuration immediately.
2324

2425
## Configuration
2526

setup.sh renamed to baseline/setup.sh

+2-50
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ set -x
66
# Add repositories
77
zypper --non-interactive ar http://download.opensuse.org/repositories/devel:/languages:/php/openSUSE_Leap_42.1/ php
88
zypper --non-interactive ar http://download.opensuse.org/repositories/home:/marec2000:/nodejs/openSUSE_Leap_42.1/ nodejs
9+
zypper --non-interactive ar http://download.opensuse.org/repositories/devel:/languages:/python/openSUSE_Leap_42.1/ python
910

1011
# Install Git before we add the SCM repository (the SCM repository contains Git 2.11, which is broken).
1112
zypper --gpg-auto-import-keys --non-interactive in --force-resolution git
@@ -24,7 +25,7 @@ fi
2425
zypper --non-interactive ar http://download.opensuse.org/repositories/devel:/tools:/scm/openSUSE_Leap_42.1/ scm
2526

2627
# Install requirements
27-
zypper --gpg-auto-import-keys --non-interactive in --force-resolution nginx php-fpm php5-mbstring php5-mysql php5-curl php5-pcntl php5-gd php5-openssl php5-ldap php5-fileinfo php5-posix php5-json php5-iconv php5-ctype php5-zip php5-sockets which python-Pygments nodejs ca-certificates ca-certificates-mozilla ca-certificates-cacert sudo subversion mercurial php5-xmlwriter nodejs-ws php5-opcache ImageMagick postfix glibc-locale
28+
zypper --gpg-auto-import-keys --non-interactive in --force-resolution nginx php-fpm php5-mbstring php5-mysql php5-curl php5-pcntl php5-gd php5-openssl php5-ldap php5-fileinfo php5-posix php5-json php5-iconv php5-ctype php5-zip php5-sockets which python-Pygments nodejs ca-certificates ca-certificates-mozilla ca-certificates-cacert sudo subversion mercurial php5-xmlwriter nodejs-ws php5-opcache ImageMagick postfix glibc-locale supervisor
2829

2930
# Build and install APCu
3031
zypper --non-interactive install --force-resolution autoconf automake binutils cpp cpp48 gcc gcc48 glibc-devel libasan0 libatomic1 libcloog-isl4 libgomp1 libisl10 libitm1 libltdl7 libmpc3 libmpfr4 libpcre16-0 libpcrecpp0 libpcreposix0 libstdc++-devel libstdc++48-devel libtool libtsan0 libxml2-devel libxml2-tools linux-glibc-devel m4 make ncurses-devel pcre-devel php5-devel php5-pear php5-zlib pkg-config readline-devel tack xz-devel zlib-devel
@@ -40,36 +41,6 @@ zypper --non-interactive install --force-resolution mariadb-client vim vim-data
4041
# Force reinstall cronie
4142
zypper --non-interactive install -f cronie
4243

43-
# Move preflight files to their locations
44-
cd /preflight
45-
mv nginx.conf /etc/nginx/nginx.conf
46-
mv server-http.conf /etc/nginx/disabled-server-http.conf
47-
mv server-https-letsencrypt.conf /etc/nginx/disabled-server-https-letsencrypt.conf
48-
mv server-https-manual.conf /etc/nginx/disabled-server-https-manual.conf
49-
mv fastcgi.conf /etc/nginx/fastcgi.conf
50-
mkdir /etc/init.simple
51-
mv 15-https /etc/init.simple/15-https
52-
mv 25-nginx /etc/init.simple/25-nginx
53-
mv 25-php-fpm /etc/init.simple/25-php-fpm
54-
mv 20-postfix /etc/init.simple/20-postfix
55-
mv 10-boot-conf /etc/init.simple/10-boot-conf
56-
mv 35-phd /etc/init.simple/35-phd
57-
mv 40-aphlict /etc/init.simple/40-aphlict
58-
mv 50-cronie /etc/init.simple/50-cronie
59-
mv 60-iomonitor /etc/init.simple/60-iomonitor
60-
mv php-fpm.conf /etc/php5/fpm/php-fpm.conf.template
61-
mv php.ini /etc/php5/fpm/php.ini
62-
mkdir /etc/phabricator-ssh
63-
mv sshd_config.phabricator /etc/phabricator-ssh/sshd_config.phabricator.template
64-
mv 45-phabricator-ssh /etc/init.simple/45-phabricator-ssh
65-
mv phabricator-ssh-hook.sh /etc/phabricator-ssh/phabricator-ssh-hook.sh.template
66-
mv bake /bake
67-
mkdir /opt/iomonitor
68-
mv iomonitor /opt/iomonitor
69-
rm setup.sh
70-
cd /
71-
rmdir /preflight # This should now be empty; it's an error if it's not.
72-
7344
# Create users and groups
7445
echo "nginx:x:497:495:user for nginx:/var/lib/nginx:/bin/false" >> /etc/passwd
7546
echo "nginx:!:495:" >> /etc/group
@@ -91,22 +62,3 @@ git clone https://github.com/letsencrypt/letsencrypt /srv/letsencrypt
9162
cd /srv/letsencrypt
9263
./letsencrypt-auto-source/letsencrypt-auto --help
9364
cd /
94-
95-
# Install PHPExcel
96-
echo '' >> /etc/php5/fpm/php-fpm.conf
97-
echo 'php_value[include_path] = "/srv/phabricator/PHPExcel/Classes"' >> /etc/php5/fpm/php-fpm.conf
98-
99-
# [chmod] init scripts
100-
chmod -R 755 /etc/init.simple
101-
102-
# Move the default SSH to port 24
103-
echo "" >> /etc/ssh/sshd_config
104-
echo "Port 24" >> /etc/ssh/sshd_config
105-
106-
# Configure Phabricator SSH service
107-
chown root:root /etc/phabricator-ssh/*
108-
109-
# Workaround for https://gist.github.com/porjo/35ea98cb64553c0c718a
110-
chmod u+s /usr/sbin/postdrop
111-
chmod u+s /usr/sbin/postqueue
112-

docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ services:
1919
- MYSQL_PASS=phabricator
2020
- PHABRICATOR_REPOSITORY_PATH=/repos
2121
- PHABRICATOR_HOST=myphabricator.com
22-
image: hachque/phabricator
22+
image: redpointgames/phabricator
2323
mysql:
2424
restart: always
2525
volumes:

10-boot-conf renamed to preflight/10-boot-conf

+14
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ if [ "$MYSQL_STORAGE_NAMESPACE" == "" ]; then
2222
MYSQL_STORAGE_NAMESPACE=phabricator
2323
fi
2424

25+
if [ "${MYSQL_PORT:0:6}" == "tcp://" ]; then
26+
echo "Error: MYSQL_PORT environment variable has been set based on a container link called mysql. This places an invalid value inside MYSQL_PORT, which causes Phabricator startup to fail later on. When using a linked container called mysql, you should explicitly set MYSQL_PORT=3306 to ensure it has a valid value."
27+
exit 1
28+
fi
29+
2530
if [ "$SSL_TYPE" == "" ]; then
2631
SSL_TYPE=none
2732
fi
@@ -78,6 +83,7 @@ if [ -d /config/keycache ]; then
7883
PHABRICATOR_HOST_KEYS_PATH="/config/keycache"
7984
fi
8085

86+
set +x
8187
cat >/config.saved <<EOF
8288
OVERRIDE_PHABRICATOR_URI="$OVERRIDE_PHABRICATOR_URI"
8389
OVERRIDE_PHABRICATOR_BRANCH="$OVERRIDE_PHABRICATOR_BRANCH"
@@ -99,7 +105,9 @@ AWS_S3_SECRET_KEY="$AWS_S3_SECRET_KEY"
99105
MYSQL_HOST="$MYSQL_HOST"
100106
MYSQL_PORT="$MYSQL_PORT"
101107
MYSQL_USER="$MYSQL_USER"
108+
set +x
102109
MYSQL_PASS="$MYSQL_PASS"
110+
set -x
103111
MYSQL_STORAGE_NAMESPACE="$MYSQL_STORAGE_NAMESPACE"
104112
ENABLE_APCU="$ENABLE_APCU"
105113
ENABLE_UPDATE_ON_START="$ENABLE_UPDATE_ON_START"
@@ -115,6 +123,7 @@ SCRIPT_BEFORE_DAEMONS="$SCRIPT_BEFORE_DAEMONS"
115123
SCRIPT_AFTER_DAEMONS="$SCRIPT_AFTER_DAEMONS"
116124
DISABLE_IOMONITOR="$DISABLE_IOMONITOR"
117125
EOF
126+
set -x
118127

119128
# Reload configuration
120129
source /config.saved
@@ -181,9 +190,11 @@ fi
181190
if [ "$MYSQL_USER" != "" ]; then
182191
sudo -u "$PHABRICATOR_VCS_USER" ./bin/config set mysql.user "$MYSQL_USER"
183192
fi
193+
set +x
184194
if [ "$MYSQL_PASS" != "" ]; then
185195
sudo -u "$PHABRICATOR_VCS_USER" ./bin/config set mysql.pass "$MYSQL_PASS"
186196
fi
197+
set -x
187198
if [ "$MYSQL_STORAGE_NAMESPACE" != "" ]; then
188199
sudo -u "$PHABRICATOR_VCS_USER" ./bin/config set storage.default-namespace "$MYSQL_STORAGE_NAMESPACE"
189200
fi
@@ -205,6 +216,7 @@ if [ "$PHABRICATOR_VCS_PORT" != "" ]; then
205216
sudo -u "$PHABRICATOR_VCS_USER" ./bin/config set diffusion.ssh-port "$PHABRICATOR_VCS_PORT"
206217
fi
207218
sudo -u "$PHABRICATOR_VCS_USER" ./bin/config set phd.user "$PHABRICATOR_VCS_USER"
219+
sudo -u "$PHABRICATOR_VCS_USER" ./bin/config set diffusion.ssh-user "$PHABRICATOR_VCS_USER"
208220
sudo -u "$PHABRICATOR_VCS_USER" ./bin/config set pygments.enabled true
209221
if [ "$PHABRICATOR_REPOSITORY_PATH" != "" ]; then
210222
sudo -u "$PHABRICATOR_VCS_USER" ./bin/config set repository.default-local-path "$PHABRICATOR_REPOSITORY_PATH"
@@ -252,7 +264,9 @@ fi
252264

253265
# The search database may need to be repaired, and if so, will prevent bin/storage upgrade from working
254266
# so preemptively run a repair on that database now.
267+
set +x
255268
mysqlcheck --host="$MYSQL_HOST" --port="$MYSQL_PORT" --user="$MYSQL_USER" --password="$MYSQL_PASS" --databases "${MYSQL_STORAGE_NAMESPACE}_search" || true
269+
set -x
256270

257271
/srv/phabricator/phabricator/bin/storage upgrade --force
258272

0 commit comments

Comments
 (0)