Skip to content

Commit ccb35e6

Browse files
committed
Feat: import code from old project
1 parent 15f9c73 commit ccb35e6

32 files changed

+2066
-0
lines changed

ADVANCED-CONFIG.md

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Advanced Configuration
2+
3+
If you want to perform any of the following customizations to Phabricator:
4+
5+
* Using different source repositories (for patched versions of Phabricator)
6+
* Running custom commands during the boot process, and
7+
* Baking configuration into your own derived Docker image
8+
9+
then this is the guide to read.
10+
11+
# Using different source repositories
12+
13+
If you have a custom version of Phabricator with patches, you can change the Git URLs and branches that the image uses with the following environment variables:
14+
15+
- `OVERRIDE_PHABRICATOR_URI` - Changes the Git URI to clone Phabricator from.
16+
- `OVERRIDE_PHABRICATOR_BRANCH` - Changes the Git branch or commit to use for the Phabricator repository.
17+
- `OVERRIDE_ARCANIST_URI` - Changes the Git URI to clone Arcanist from.
18+
- `OVERRIDE_ARCANIST_BRANCH` - Changes the Git branch or commit to use for the Arcanist repository.
19+
- `OVERRIDE_LIBPHUTIL_URI` - Changes the Git URI to clone libphutil from.
20+
- `OVERRIDE_LIBPHUTIL_BRANCH` - Changes the Git branch or commit to use for the libphutil repository.
21+
22+
For example:
23+
24+
```
25+
docker run ... \
26+
--env OVERRIDE_PHABRICATOR_URI='https://github.com/mycompany/phabricator' \
27+
...
28+
```
29+
30+
# Running custom commands during the boot process
31+
32+
At various stages of the boot process, you can run custom scripts to insert additional configuration into how Phabricator is set up, such as adding external libraries. You can use the following environment variables to point to custom scripts:
33+
34+
- `SCRIPT_BEFORE_UPDATE` - Occurs before everything else, including before Phabricator and it's associated repositories are updated.
35+
- `SCRIPT_BEFORE_MIGRATION` - Occurs after Phabricator is updated, but before the database migration scripts are run. You can use this to clone additional libphutil libraries next to Phabricator, and you can use this to modify MySQL connection information.
36+
- `SCRIPT_AFTER_MIGRATION` - Occurs after database scripts have been run.
37+
- `SCRIPT_AFTER_LETS_ENCRYPT` - Occurs after Let's Encrypt has registered domains. You can use this script to register additional domains that aren't specified by `PHABRICATOR_HOST` or `PHABRICATOR_CDN`. This only runs if SSL is set to the Let's Encrypt mode.
38+
- `SCRIPT_BEFORE_DAEMONS` - Occurs before background daemons are launched.
39+
- `SCRIPT_AFTER_DAEMONS` - Occurs after background daemons are launched. You can use this to launch additional daemons.
40+
41+
For example, if you wanted to add an external libphutil library, you might configure the image like this:
42+
43+
```
44+
docker run ... \
45+
--env SCRIPT_BEFORE_MIGRATION=/scripts/beforemig.sh \
46+
-v /hostscripts:/scripts \
47+
...
48+
```
49+
50+
Then inside `/hostscripts` on the host you'd have the following executable shell script:
51+
52+
```
53+
#!/bin/bash
54+
55+
git clone https://github.com/mycompany/my-extension /srv/phabricator/my-extension
56+
cd /srv/phabricator/phabricator
57+
sudo -u "$PHABRICATOR_VCS_USER" ./bin/config set load-libraries '["/srv/phabricator/my-extension"]'
58+
```
59+
60+
# Baking configuration into an image
61+
62+
You can bake the configuration and initial start-up of this image into your own derived image. The benefits of doing this are:
63+
64+
* The start-up of the image will be faster, as the one-time processes will have already been done
65+
* You can push this image to a private repository and use it to run a Phabricator cluster
66+
67+
To bake an image, create a `Dockerfile` like this:
68+
69+
```
70+
FROM redpointgames/phabricator
71+
72+
ADD my-script /my-script
73+
RUN /my-script
74+
```
75+
76+
then create `my-script` like this:
77+
78+
```
79+
#!/bin/bash
80+
81+
set -e
82+
set -x
83+
84+
export MYSQL_HOST="..."
85+
# .. export more configuration values here ..
86+
87+
/bake /my-script
88+
```
89+
90+
You can set the advanced environment variables for hooking scripts as documented in [Full Environment Variable Reference](ENV-LIST.md), and add those
91+
scripts to your image so they run each time.
92+
93+
When writing custom scripts for your image, you can check if the script is being run during the initial bake process by checking with:
94+
95+
```
96+
if [ -f /is-baking ]; then
97+
```
98+
99+
Likewise, you can check if you are not doing an initial bake (non-baked start up, or start up after bake), with:
100+
101+
```
102+
if [ ! -f /is-baking ]; then
103+
```
104+
105+
You can check if the script is running after the image has been baked with:
106+
107+
```
108+
if [ -f /baked ]; then
109+
```
110+
111+
Likewise, you can check if you are not running in a baked image (non-baked start up, or during initial bake), with:
112+
113+
```
114+
if [ ! -f /baked ]; then
115+
```

BASIC-CONFIG.md

+152
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# Basic Configuration
2+
3+
For most basic setups, you can use environment variables to configure the Phabricator image to your liking. This works well with tools like `docker-compose`.
4+
5+
A full list of all available environment variables can be found in the [Full Environment Variable List](ENV-LIST.md).
6+
7+
# Configuring GIT user
8+
9+
```
10+
docker run ... \
11+
--env GIT_USER="John Doe" \
12+
--env GIT_EMAIL="jd@foo.com" \
13+
--env GIT_EDITOR=/usr/bin/vim \
14+
...
15+
```
16+
17+
18+
# Configuring MySQL
19+
20+
You need to do this before running the container, or things won't work. If you have MySQL running in another container, you can use `MYSQL_HOST`, like so:
21+
22+
```
23+
docker run ... \
24+
--env MYSQL_HOST=mysql \
25+
--env MYSQL_USER=phabricator \
26+
--env MYSQL_PASS=password \
27+
--link somecontainer:mysql \
28+
...
29+
```
30+
31+
If your instance of MySQL is running on the host or some external system, you can connect to it using the `MYSQL_USER` and associated variables like so:
32+
33+
```
34+
docker run \
35+
--env MYSQL_HOST=externalhost.com \
36+
--env MYSQL_PORT=3306 \
37+
--env MYSQL_USER=phabricator \
38+
--env MYSQL_PASS=password \
39+
...
40+
```
41+
42+
The `MYSQL_PORT` environment variable is set to a sensible default, so normally you don't need to explicitly provide it.
43+
44+
# Configuring Phabricator
45+
46+
Phabricator needs some basic information about how clients will connect to it. You can provide the base URI for Phabricator with the `PHABRICATOR_HOST` environment variable, like so:
47+
48+
```
49+
docker run ... \
50+
--env PHABRICATOR_HOST=myphabricator.com \
51+
...
52+
```
53+
54+
It's recommended that you specify an alternate domain to serve files and other user content from. This will make Phabricator more secure. You can configure this using the `PHABRICATOR_CDN` option, like so:
55+
56+
```
57+
docker run ... \
58+
--env PHABRICATOR_CDN=altdomain.com \
59+
...
60+
```
61+
62+
When using the Let's Encrypt SSL configuration, it will automatically register both domains.
63+
64+
You also need to configure a place to store repository data. This should be a volume mapped from the host, for example:
65+
66+
```
67+
docker run ... \
68+
--env PHABRICATOR_REPOSITORY_PATH=/repos \
69+
-v /path/on/host:/repos \
70+
...
71+
```
72+
73+
To provide SSH access to repositories, you need to set a path to store the SSH host keys in. If you are not baking a derived image (see [Advanced Configuration](ADVANCED-CONFIG.md)), then you need to map that path to a location on the host. If you are baking an image, you can omit the mapping and the SSH keys will form part of your derived image. You can configure SSH access to repositories like so:
74+
75+
```
76+
docker run ... \
77+
--env PHABRICATOR_HOST_KEYS_PATH=/hostkeys/persisted \
78+
-v /path/on/host:/hostkeys \
79+
...
80+
```
81+
82+
By default, Phabricator stores file data in MySQL. You can change this with the `PHABRICATOR_STORAGE_TYPE` option, which can be either `mysql` (the default), `disk` or `s3`.
83+
84+
You can configure Phabricator to store files on disk by selecting the `disk` option, mapping a volume and configuring the path:
85+
86+
```
87+
docker run ... \
88+
--env PHABRICATOR_STORAGE_TYPE=disk \
89+
--env PHABRICATOR_STORAGE_PATH=/files \
90+
-v /path/on/host:/files \
91+
...
92+
```
93+
94+
Alternatively if you want to store file data in S3, you can do so by selecting the `s3` option, configuring the bucket and setting the AWS access and secret keys to use:
95+
96+
```
97+
docker run ... \
98+
--env PHABRICATOR_STORAGE_TYPE=s3 \
99+
--env PHABRICATOR_STORAGE_BUCKET=mybucket \
100+
--env AWS_S3_ACCESS_KEY=... \
101+
--env AWS_S3_SECRET_KEY=... \
102+
...
103+
```
104+
105+
# Configuring SSL
106+
107+
You can configure SSL in one of three ways: you can omit it entirely, you can turn on the automatic Let's Encrypt registration or you can provide SSL certificates.
108+
109+
## No SSL
110+
111+
This is the default. If you provide no SSL related options, this image doesn't serve anything on port 443 (HTTPS).
112+
113+
## Load Balancer terminated SSL
114+
115+
If your load balancer is terminating SSL, you should set `SSL_TYPE` to `external` so that Phabricator will render out all links as HTTPS. Without doing this (i.e. if you left the default of `none`), all of the Phabricator URLs would be prefixed with `http://` instead of `https://`.
116+
117+
**NOTE:** If you use Load Balancer terminated SSL, things like real-time notifications are unlikely to work correctly. It's recommended that you let the Docker instance terminate the SSL connection, and use TCP forwarding in any load balancer configuration you might have set up.
118+
119+
```
120+
docker run ... \
121+
--env SSL_TYPE=external \
122+
...
123+
```
124+
125+
## Automatic SSL via Let's Encrypt
126+
127+
For this to work, you need to provide a volume mapped to `/config`, so that the image can store certificates across restarts. You also need to set `PHABRICATOR_HOST` and optionally `PHABRICATOR_CDN` as documented above.
128+
129+
To enable automated SSL via Let's Encrypt, provide the following environment variables:
130+
131+
```
132+
docker run ... \
133+
--env SSL_TYPE=letsencrypt \
134+
--env SSL_EMAIL='youremail@domain.com' \
135+
--env PHABRICATOR_HOST=myphabricator.com \
136+
--env PHABRICATOR_CDN=altdomain.com \
137+
-v /some/host/path:/config \
138+
...
139+
```
140+
141+
## Manual SSL
142+
143+
If you want to provide your own certificates, map a volume containing your certificates and set the appropriate environment variables:
144+
145+
```
146+
docker run ... \
147+
--env SSL_TYPE=manual \
148+
--env SSL_CERTIFICATE=/ssl/cert.pem \
149+
--env SSL_PRIVATE_KEY=/ssl/cert.key \
150+
-v /host/folder/containing/certs:/ssl \
151+
...
152+
```

DOCKER-COMPOSE.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Launch Phabricator with docker-compose command
2+
3+
Docker Compose configuration file supplied in this repository defines a Phabricator service and a MySQL service.
4+
5+
The MySQL service uses official MySQL Docker image mysql:5.7.14 and the Phabricator service uses image redpointgames/phabricator.
6+
7+
8+
## Configure `PHABRICATOR_HOST`
9+
10+
Before you start, you should modify the `PHABRICATOR_HOST` inside docker-compose.yml so that `PHABRICATOR_HOST` represents the real domain name you want to use.
11+
12+
If you do not modify the `PHABRICATOR_HOST`, Phabricator will not function correctly.
13+
14+
## Docker Volume
15+
16+
By default, it tries to mount host directory /srv/docker/phabricator/mysql as /var/lib/mysql in MySQL service container and host directory /srv/docker/phabricator/repos as /repo in Phabricator service container.
17+
18+
It mounts host directory /srv/docker/phabricator/extensions as /srv/phabricator/phabricator/src/extensions in Phabricator service.
19+
20+
If you would like to add additional translations for phabricator, you can just drop php files in host directory /srv/docker/phabricator/extensions.
21+
22+
To ensure that MySQL database and code repositories are both persistent, please make sure the following directories exist in your docker host.
23+
24+
```bash
25+
/srv/docker/phabricator/repos
26+
/srv/docker/phabricator/mysql
27+
```
28+
29+
The following directory is optional and can be absent in your docker host.
30+
31+
```bash
32+
/srv/docker/phabricator/extensions
33+
```
34+
35+
It is required if you need extra Phabricator translations.
36+
37+
## Launch Phabricator
38+
39+
Once you configure `PHABRICATOR_HOST` and Docker Volume, you can run the following command within the directory where docker-compose.yml resides.
40+
41+
To launch Phabricator in daemon mode
42+
43+
```bash
44+
docker-compose up -d
45+
```
46+
47+
To launch Phabricator in interactive mode
48+
49+
```bash
50+
docker-compose up
51+
```

Dockerfile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM opensuse/leap:15.0
2+
3+
EXPOSE 80 443 2222 24
4+
COPY baseline /baseline
5+
RUN /baseline/repository.sh
6+
RUN /baseline/setup.sh
7+
COPY preflight /preflight
8+
RUN /preflight/setup.sh
9+
CMD ["/bin/bash", "/app/init.sh"]
10+
#CMD ["/bin/bash"]

ENV-LIST.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Full Environment Variable Reference
2+
3+
- `PHABRICATOR_HOST` - The FQDN which is served by this Phabricator (standalone setu) of by the whole cluster (cluster setup).
4+
- `PHABRICATOR_CDN` - The domain name to use for serving files and other user content (optional, but recommended).
5+
- `PHABRICATOR_REPOSITORY_PATH` - The path to store repository data in. This directory should be a volume mapped from the host, otherwise repository data will be lost when the container is destroyed.
6+
- `PHABRICATOR_STORAGE_TYPE` - The type of storage to use for files. Defaults to `mysql`, but you can set it to `disk` or `s3` for alterate storage options (see [Basic Configuration](BASIC-CONFIG.md)).
7+
- `PHABRICATOR_STORAGE_PATH` - When using the `disk` type of storage, specifies the path in the container that's been mapped to the host for permanent file storage. This should be a different path to `PHABRICATOR_REPOSITORY_PATH`.
8+
- `PHABRICATOR_STORAGE_BUCKET` - When using the `s3` type of storage, specifies the bucket to store files in.
9+
- `PHABRICATOR_VCS_USER` - The user name for SSH access. Defaults to `git`.
10+
- `PHABRICATOR_VCS_PORT` - The Docker-exposed port used for SSH access. Sets `diffusion.ssh-port`, which affects the URI displayed in Diffusion.
11+
- `PHABRICATOR_HOST_KEYS_PATH` - The path to store SSH host keys in. This directory should be a volume mapped from the host, otherwise clients will be unable to connect after the container is restarted.
12+
- `AWS_S3_ACCESS_KEY` - The AWS access key to use for S3. Only needed when the `s3` storage type is selected.
13+
- `AWS_S3_SECRET_KEY` - The AWS secret key to use for S3. Only needed when the `s3` storage type is selected.
14+
- `MYSQL_HOST` - Use this if you want to connect to an external MySQL host (see [Basic Configuration](BASIC-CONFIG.md)).
15+
- `MYSQL_PORT` - When connecting to an external MySQL host, use this port (optional).
16+
- `MYSQL_USER` - The user to connect to MySQL as.
17+
- `MYSQL_PASS` - The password to connect to MySQL.
18+
- `MYSQL_STORAGE_NAMESPACE` - The prefix to use for database names (optional, defaults to "phabricator").
19+
- `ENABLE_APCU` - Enable the APCu extension for PHP. This may improve performance, but is not as stable as regular PHP.
20+
- `ENABLE_UPDATE_ON_START` - By default this image uses the version of Phabricator baked into the image when it was made. By setting this to "true", it will fetch the latest version of Phabricator when the image starts.
21+
- `SSL_TYPE` - One of "none", "manual", "external" or "letsencrypt". See [Basic Configuration](BASIC-CONFIG.md) for more information (defaults to "none").
22+
- `SSL_CERTIFICATE` - The path to the SSL certificate chain (manual mode only).
23+
- `SSL_PRIVATE_KEY` - The path to the SSL private key (manual mode only).
24+
- `SSL_EMAIL` - The email address to use when registering for an SSL certificate (Let's Encrypt mode only)
25+
- `SSL_DOMAINS` - An optional comma seperated list of the domains to issue for, in addition to `PHABRICATOR_HOST` (Let's Encrypt mode only)
26+
- `DISABLE_IOMONITOR` - Disable the I/O monitor, which warns if the image is spending a lot of CPU time waiting on disk I/O.
27+
28+
The following advanced options automatically turn on `ENABLE_UPDATE_ON_START`:
29+
30+
- `OVERRIDE_PHABRICATOR_URI` - Changes the Git URI to clone Phabricator from.
31+
- `OVERRIDE_PHABRICATOR_BRANCH` - Changes the Git branch or commit to use for the Phabricator repository.
32+
- `OVERRIDE_ARCANIST_URI` - Changes the Git URI to clone Arcanist from.
33+
- `OVERRIDE_ARCANIST_BRANCH` - Changes the Git branch or commit to use for the Arcanist repository.
34+
- `OVERRIDE_LIBPHUTIL_URI` - Changes the Git URI to clone libphutil from.
35+
- `OVERRIDE_LIBPHUTIL_BRANCH` - Changes the Git branch or commit to use for the libphutil repository.
36+
37+
The following advanced options allow you to run custom scripts during stages of the boot process:
38+
39+
- `SCRIPT_BEFORE_UPDATE` - Occurs before everything else, including before Phabricator and it's associated repositories are updated.
40+
- `SCRIPT_BEFORE_MIGRATION` - Occurs after Phabricator is updated, but before the database migration scripts are run. You can use this to clone additional libphutil libraries next to Phabricator, and you can use this to modify MySQL connection information.
41+
- `SCRIPT_AFTER_MIGRATION` - Occurs after database scripts have been run.
42+
- `SCRIPT_AFTER_LETS_ENCRYPT` - Occurs after Let's Encrypt has registered domains. You can use this script to register additional domains that aren't specified by `PHABRICATOR_HOST` or `PHABRICATOR_CDN`. This only runs if SSL is set to the Let's Encrypt mode.
43+
- `SCRIPT_BEFORE_DAEMONS` - Occurs before background daemons are launched.
44+
- `SCRIPT_AFTER_DAEMONS` - Occurs after background daemons are launched. You can use this to launch additional daemons.
45+
- `PHABRICATOR_ALLOW_HTTP_AUTH` - Sets the diffusion.allow-http-auth config key
46+
- `PHABRICATOR_CLUSTER_DATABASE_JSON` - Sets cluster.databases config key. Expects a JSON file.
47+
- `PHABRICATOR_CLUSTER_MAILER_JSON` - Sets cluster.mailers config key. Expects a JSON file.
48+
- `PHABRICATOR_CLUSTER_ADDRESSES_JSON` - Sets cluster.addresses config key. Expects a JSON file.
49+
- `PHABRICATOR_CLUSTER_DEVICE_KEY` - Give path to the private key to be used for this cluster device registration. The key is provided by Almanac application, in Phabricator.
50+
- `PHABRICATOR_CLUSTER_DEVICE_HOST` - Give the FQDN or ip address of this cluster node.
51+
- `UPGRADE_STORAGE` - Tell the container to upgrade the storage when booting. Do not activate this in cluster setup.
52+
- `PHABRICATOR_ENV_APPEND_PATH_JSON` - Sets environment.append-paths config key. Add some paths to the Phabricator environment.
53+
- `ADD_SSL_TERMINATION_PREAMBLE` - Add PHP preamble when the installation is behind a SSL terminator (reverse proxy, load-balancer). See [Phabricator documentation about this](https://secure.phabricator.com/book/phabricator/article/configuring_preamble/).

0 commit comments

Comments
 (0)