Page MenuHomePhorge

No OneTemporary

diff --git a/.env b/.env
new file mode 100644
index 0000000..f33ed1e
--- /dev/null
+++ b/.env
@@ -0,0 +1,4 @@
+INSTALLDIR=/var/www/phacility
+HOST=phabricator.test
+PORT=80
+
diff --git a/Dockerfile b/Dockerfile
index 2c4d633..f0cbc1e 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,45 +1,58 @@
-FROM ubuntu:22.04
+FROM ubuntu:22.04 as phabdev_base
RUN apt-get update && \
apt-get upgrade -y
ENV DEBIAN_FRONTEND noninteractive
-RUN apt-get install -y sudo netcat-traditional iputils-ping git nginx mariadb-client ca-certificates software-properties-common apt-transport-https && \
+RUN apt-get install -y sudo netcat-traditional iputils-ping ca-certificates software-properties-common apt-transport-https && \
+ apt-get install -y mariadb-client nginx && \
+ apt-get install -y git mercurial && \
+ apt-get install -y vim less ripgrep fd-find && \
add-apt-repository -y ppa:ondrej/php && \
apt-get update && \
- apt-get install -y php7.4 php7.4-fpm php7.4-mysql php7.4-gd php7.4-curl php7.4-apcu php7.4-cli php7.4-mbstring php7.4-zip php7.4-xdebug php7.4-iconv
+ apt-get install -y php7.4 php7.4-fpm php7.4-mysql php7.4-gd php7.4-curl php7.4-apcu php7.4-cli php7.4-mbstring php7.4-zip php7.4-xdebug php7.4-iconv && \
+ apt-get install -y python3 python3-pip && \
+ pip install Pygments
+
+FROM phabdev_base
+
+ENV INSTALLDIR=$INSTALLDIR
+ENV HOST=$HOST
+ENV PORT=$PORT
ADD ./conf/nginx.conf /etc/nginx/
ADD ./conf/phab.conf /etc/nginx/conf.d/
ADD ./conf/www.conf /etc/php/7.4/fpm/pool.d/
+ADD ./conf/00-phab.ini /etc/php/7.4/fpm/conf.d/
# Allow www-data (entrypoint) to sudo as root to run nginx
RUN echo "www-data ALL=(root) NOPASSWD: /usr/sbin/nginx" >> /etc/sudoers && \
echo "www-data ALL=(root) NOPASSWD: /usr/sbin/php-fpm7.4" >> /etc/sudoers && \
echo "www-data ALL=(phab-phd) NOPASSWD: ALL" >> /etc/sudoers && \
+ echo "www-data ALL=(root) NOPASSWD: /usr/bin/sed" >> /etc/sudoers && \
echo "phab-phd ALL=(root) NOPASSWD: ALL" >> /etc/sudoers
RUN useradd --system phab-phd && \
groupadd phab && \
usermod -a -G phab phab-phd && \
usermod -a -G phab www-data
RUN mkdir -p /opt/phabdev/ && \
mkdir -p /opt/filestore && \
mkdir -p /opt/repos && \
mkdir -p /var/log/phabricator && \
mkdir -p /run/php/
RUN chown -R phab-phd:phab /opt/ && \
chown -R www-data:phab /var/log/phabricator/ && \
chmod -R g+rw /opt/ && \
chmod -R g+rw /var/log/phabricator/
# Run entrypoint as the web service account
USER www-data
ADD ./conf/local.json /opt/phabdev
ADD ./conf/entrypoint.sh /opt/phabdev
ENTRYPOINT ["/opt/phabdev/entrypoint.sh"]
diff --git a/conf/00-phab-mysql.cnf b/conf/00-phab-mysql.cnf
new file mode 100644
index 0000000..53cbfb0
--- /dev/null
+++ b/conf/00-phab-mysql.cnf
@@ -0,0 +1,6 @@
+[mysqld]
+max_allowed_packet = 128M
+sql_mode = STRICT_ALL_TABLES
+innodb_buffer_pool_size = 1600M
+local_infile = 0
+
diff --git a/conf/00-phab.ini b/conf/00-phab.ini
new file mode 100644
index 0000000..d35158e
--- /dev/null
+++ b/conf/00-phab.ini
@@ -0,0 +1,3 @@
+post_max_size = 256M
+opcache.validate_timestamps = 1
+opcache.revalidate_freq = 0
diff --git a/conf/entrypoint.sh b/conf/entrypoint.sh
index acfba29..edd4c3b 100755
--- a/conf/entrypoint.sh
+++ b/conf/entrypoint.sh
@@ -1,27 +1,42 @@
#!/bin/bash
-installdir=/var/www/phabricator
+set -e
+#set -x
-# The install directory is mapped to a local folder. Only copy this default config
-# over if there isn't one already, otherwise use the one that's there.
-if [[ ! -f "$installdir/conf/local.json" ]]; then
- mv /opt/phabdev/local.json $installdir/conf/local/
+installdir=$INSTALLDIR
+host=$HOST
+port=$PORT
+
+if [ "$PORT" = "80" ]; then
+ base_uri=http://$host
+else
+ base_uri=http://$host:$port
fi
+mv /opt/phabdev/local.json $installdir/conf/local/
+
+escaped_base_uri=$(printf '%s\n' "$base_uri" | sed -e 's/[\/&]/\\&/g')
+sed -i 's/BASE_URI/'${escaped_base_uri}'/g' $installdir/conf/local/local.json
+
+escaped_installdir=$(printf '%s\n' "$INSTALLDIR" | sed -e 's/[\/&]/\\&/g')
+sudo sed -i 's/PHABDEV_HOST/'${HOST}'/g' /etc/nginx/conf.d/phab.conf
+sudo sed -i 's/PHABDEV_INSTALLDIR/'${escaped_installdir}'/g' /etc/nginx/conf.d/phab.conf
+
# Wait for mysql
while ! nc -z phabdev-db 3306 2>/dev/null
do
sleep 0.1
done
mariadb --host=phabdev-db --user=root --password=phabricator_secret --execute="GRANT ALL PRIVILEGES ON *.* TO 'phabricator'@'%' IDENTIFIED BY 'phabricator' WITH GRANT OPTION;"
$installdir/bin/storage upgrade --force
sudo -u phab-phd $installdir/bin/phd start
sudo php-fpm7.4 --daemonize
-echo "Starting web server on http://localhost:8080 ..."
+echo "(Remember to update /etc/hosts to include \"127.0.0.1 $host\")"
+echo "Starting web server on $base_uri ..."
exec sudo nginx
diff --git a/conf/local.json b/conf/local.json
index 633cc0f..d044af3 100644
--- a/conf/local.json
+++ b/conf/local.json
@@ -1,12 +1,16 @@
{
+ "phabricator.developer-mode": true,
"phabricator.silent": true,
"log.access.path": "/var/log/phabricator/access.log",
"repository.default-local-path": "/opt/repos",
"storage.default-namespace": "phabricator",
"mysql.pass": "phabricator",
"mysql.user": "phabricator",
"mysql.host": "phabdev-db",
"storage.local-disk.path": "/opt/filestore",
"phd.user": "phab-phd",
- "phabricator.base-uri": "http://phabricator.dev"
+ "phabricator.base-uri": "BASE_URI",
+ "pygments.enabled": true,
+
+ "phabricator.timezone": "America/New_York"
}
diff --git a/conf/phab.conf b/conf/phab.conf
index 243dd77..fa7a15f 100644
--- a/conf/phab.conf
+++ b/conf/phab.conf
@@ -1,42 +1,40 @@
# redirect all traffic to https
server {
listen 80 default_server;
listen [::]:80 default_server;
- server_name phabricator.dev;
- root /var/www/phabricator/webroot;
+ server_name PHABDEV_HOST;
+ root PHABDEV_INSTALLDIR/webroot;
client_max_body_size 512m;
location / {
index index.php;
rewrite ^/(.*)$ /index.php?__path__=/$1 last;
}
location = /favicon.ico {
try_files $uri =204;
}
location /index.php {
# php-fpm is configured to host on port 9000 for the cgi proxy
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
- #required if PHP was built with --enable-force-cgi-redirect
+ # required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
- #variables to make the $_SERVER populate in PHP
+ # variables to make the $_SERVER populate in PHP
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
-
- fastcgi_param HTTPS false;
}
}
diff --git a/docker-compose.yml b/docker-compose.yml
index 51022e6..bfbf4d8 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,46 +1,50 @@
version: "3.2"
services:
phabdev-db:
- container_name: phabdev-db
- image: mariadb
+ build:
+ context: .
+ dockerfile: mariadb.Dockerfile
restart: always
environment:
- MARIADB_ROOT_PASSWORD=phabricator_secret
networks:
- phabnet
volumes:
- db-data:/var/lib/mysql
- phabricator:
- container_name: phabdev
+ phabdev-www:
build: .
restart: "no"
networks:
- phabnet
volumes:
- - ./phabricator:/var/www/phabricator/
- - ./arcanist:/var/www/arcanist/
+ - ./phabricator:$INSTALLDIR/phabricator/
+ - ./arcanist:$INSTALLDIR/arcanist/
- filestore:/opt/filestore/
- repos:/opt/repos/
ports:
- - "8080:80"
+ - "${PORT}:80"
+ environment:
+ - INSTALLDIR=${INSTALLDIR}/phabricator
+ - HOST=${HOST}
+ - PORT=${PORT}
networks:
phabnet:
volumes:
db-data:
name: "phabdev-db"
external: false
driver: local
filestore:
name: "phabdev-filestore"
external: false
driver: local
repos:
name: "phabdev-repos"
external: false
driver: local
diff --git a/mariadb.Dockerfile b/mariadb.Dockerfile
new file mode 100644
index 0000000..e2b9336
--- /dev/null
+++ b/mariadb.Dockerfile
@@ -0,0 +1,4 @@
+FROM mariadb
+
+ADD ./conf/00-phab-mysql.cnf /etc/mysql/conf.d/
+
diff --git a/readme.md b/readme.md
index f6fcb92..4509284 100644
--- a/readme.md
+++ b/readme.md
@@ -1,16 +1,27 @@
A docker-compose configuration for running a phabricator server for development
## Setup
1. Clone this repository
-2. Symlink `phabricator` and `arcanist` inside the repo folder
+2. Modify the `.env` file to set desired variables
+ - The `INSTALLDIR` variable should generally not be changed, it's the location within the container where phabricator/arcanist will be installed to.
+ - The `HOST` variable is the hostname for phabricator to be hosted on. Phabricator requires something with a `.` so this cannot be `localhost`. Pro-tip: do not use `something.dev` as the `.dev` TLD is a valid domain and browsers will likely force loading using HTTPS instead of HTTP.
+ - The `PORT` variable is the port to be exposed on the host, in case other services are running or you don't want to use the default port 80.
+3. Modify the `conf/local.json` file to configure for your setup
+ - Items above the blank line should generally not need configured. JSON does not support comments otherwise this would be indicated directly in the file.
+ - Update `phabricator.timezone` to match your current/local timezone. The value for this should be a valid PHP time zone.
+3. Symlink `phabricator` and `arcanist` inside the repo folder
```
$ ln -s ../phabricator phabricator
$ ln -s ../arcanist arcanist
```
-3. Start the containers
+4. Start the containers. The first time this runs the container image will be built.
```
$ docker-compose up
```
-4. Modify local `/etc/hosts` and add `127.0.0.1 phabricator.dev`
-5. Navigate to `http://phabricator.dev:8080`
+5. Modify local `/etc/hosts` and add `127.0.0.1 phabricator.test`
+6. Navigate to `http://phabricator.test`
+7. Address outstanding setup issues such as configuring an Auth Provider. These setup issues can be ignored since this is only intended for local development:
+ - Alternate File Domain Not Configured
+ - Mailers Not Configured
+If you need to modify the `.env` file after the first time running `docker-compose up` you will need to re-build using `docker-compose build --no-cache`.

File Metadata

Mime Type
text/x-diff
Expires
Jan 19 2025, 19:03 (5 w, 8 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1127667
Default Alt Text
(10 KB)

Event Timeline