Skip to content

Commit 240db71

Browse files
committed
Initial commit
0 parents  commit 240db71

18 files changed

+573
-0
lines changed

.env.dist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
HUMHUB_DOCKER_VERSION="develop"
2+
HUMHUB_DOCKER_DOMAIN="localhost"
3+
HUMHUB_DOCKER_DB_DSN="mysql:host=db;dbname=humhub"
4+
HUMHUB_DOCKER_DB_USER="root"
5+
HUMHUB_DOCKER_DB_PASSWORD="ChangeMeToSuperSecretMySqlRootPassword:-)"

.github/workflows/docker-publish.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Docker Image CI
2+
on:
3+
push:
4+
tags:
5+
- '*'
6+
workflow_dispatch:
7+
schedule:
8+
- cron: "33 3 * * *"
9+
10+
jobs:
11+
build:
12+
strategy:
13+
matrix:
14+
branch: [develop, next]
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: docker login
19+
env:
20+
DOCKER_USER: ${{secrets.DOCKER_USER}}
21+
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
22+
run: |
23+
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
24+
25+
- name: Build the Docker image
26+
run: cd image; docker build . --file Dockerfile --build-arg BRANCH=${{ matrix.branch }} --tag humhub/humhub-dev:${{ matrix.branch }}
27+
28+
- name: Docker Push
29+
run: docker push humhub/humhub-dev:${{ matrix.branch }}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.env
2+
humhub.env
3+
humhub-data
4+
caddy-data
5+
mysql-data

Caddyfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{$caddydomain} {
2+
reverse_proxy humhub:8404
3+
}

README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# HumHub - Docker Image (Development Version)
2+
3+
The Docker package provides all the essential components for setting up your HumHub installation.
4+
5+
## Features
6+
7+
- HumHub Core Software (Apache2 + FPM)
8+
- MariaDB (Database Server)
9+
- Caddy (Reverse Proxy w/ automatic LetsEncrypt SSL certificates)
10+
- Redis (Cache / Queue)
11+
12+
## Quick Start
13+
14+
### Installation
15+
16+
```
17+
git clone [email protected]:humhub/docker-dev.git /opt/humhub
18+
cd /opt/humhub
19+
20+
cp humhub.env.dist humhub.env
21+
cp .env.dist .env
22+
```
23+
24+
Then edit the `.env` file and set at least the `HUMHUB_DOCKER_DOMAIN`.
25+
26+
```
27+
docker compose up -d
28+
```
29+
30+
> On older Docker versions you may need to run `docker-compose up -d` instead.
31+
32+
Open your HumHub installation at: https://YOUR-HUMHUB_DOCKER_DOMAIN
33+
34+
> After installation, an e-mail server must be configured at: `Administration` -> `Settings` -> `Advanced` -> `E-Mail`.
35+
36+
### Upgrading
37+
38+
Running following commands in the main directory.
39+
40+
```
41+
cd /opt/humhub
42+
43+
git pull
44+
45+
docker compose pull
46+
docker compose down
47+
docker compose up -d
48+
```
49+
50+
> Also check for new configuration options in `.env.dist` and `humhub.env.dist` files.
51+
52+
## Other Setup Options
53+
54+
### HumHub CLI
55+
56+
You can use the wrapper script in the main directoy.
57+
58+
```
59+
./yii.sh help
60+
```
61+
62+
### Version Control
63+
64+
You can define the HumHub version using the variable `HUMHUB_DOCKER_VERSION`.
65+
66+
The following tags are currently available:
67+
- ~~`master` - For the current stable version~~ (not available yet)
68+
- `develop` - For the current development version
69+
- `next` - For the next development version
70+
71+
For older versions:
72+
- ~~`v1.17`~~ (not available yet)
73+
- ~~`v1.17.0-beta.1`~~ (not available yet)
74+
75+
### Custom Themes & Modules
76+
77+
You can store your own themes/modules in the folders `/opt/humhub/humhub-data/themes` and `/opt/humhub/humhub-data/custom-modules`.
78+
79+
### Existing Reverse Proxy
80+
81+
**NGINX Example:**
82+
83+
If an NGINX web server is already running on the host on which the Docker container is started on the HTTPS port, a reverse proxy to the HumHub Docker container can be created in a virtual host via the following block.
84+
85+
```
86+
location / {
87+
proxy_pass http://127.0.0.1:8404;
88+
proxy_set_header Host $http_host;
89+
proxy_set_header X-Real-IP $remote_addr;
90+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
91+
proxy_set_header X-Forwarded-Proto $scheme;
92+
}
93+
```
94+
95+
**Apache2 Example:**
96+
97+
TBD

compose.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
services:
2+
humhub:
3+
image: humhub/humhub-dev:${HUMHUB_DOCKER_VERSION}
4+
ports:
5+
- 8404:8404
6+
depends_on:
7+
db:
8+
condition: service_healthy
9+
volumes:
10+
- ./humhub-data:/var/lib/humhub
11+
env_file:
12+
- ./humhub.env
13+
environment:
14+
- HUMHUB_CONFIG__COMPONENTS__DB__DSN=${HUMHUB_DOCKER_DB_DSN}
15+
- HUMHUB_CONFIG__COMPONENTS__DB__USERNAME=${HUMHUB_DOCKER_DB_USER}
16+
- HUMHUB_CONFIG__COMPONENTS__DB__PASSWORD=${HUMHUB_DOCKER_DB_PASSWORD}
17+
- HUMHUB_FIXED_SETTINGS__BASE__BASE_URL=https://${HUMHUB_DOCKER_DOMAIN}
18+
- HUMHUB_FIXED_SETTINGS__BASE__CACHE_CLASS=yii\redis\Cache
19+
- HUMHUB_CONFIG__COMPONENTS__REDIS__CLASS=yii\redis\Connection
20+
- HUMHUB_CONFIG__COMPONENTS__REDIS__HOSTNAME=redis
21+
- HUMHUB_CONFIG__COMPONENTS__REDIS__PORT=6379
22+
- HUMHUB_CONFIG__COMPONENTS__REDIS__DATABASE=0
23+
- HUMHUB_CONFIG__COMPONENTS__SESSION__CLASS=yii\redis\Session
24+
db:
25+
image: mariadb
26+
restart: always
27+
user: root
28+
volumes:
29+
- ./mysql-data:/var/lib/mysql
30+
environment:
31+
- MYSQL_ROOT_PASSWORD=${HUMHUB_DOCKER_DB_PASSWORD}
32+
expose:
33+
- 3306
34+
healthcheck:
35+
test: ["CMD", "/usr/local/bin/healthcheck.sh", "--su-mysql", "--connect", "--innodb_initialized"]
36+
interval: 10s
37+
timeout: 5s
38+
retries: 5
39+
caddy:
40+
image: caddy:latest
41+
ports:
42+
- 80:80
43+
- 443:443
44+
volumes:
45+
- ./Caddyfile:/etc/caddy/Caddyfile
46+
- ./caddy-data:/data
47+
environment:
48+
- caddydomain=${HUMHUB_DOCKER_DOMAIN}
49+
restart: always
50+
redis:
51+
image: redis:6.2-alpine
52+
ports:
53+
- 6379:6379
54+
restart: always
55+
command: redis-server --save 20 1 --loglevel warning
56+
volumes:
57+
- cache:/data
58+
volumes:
59+
cache:
60+
driver: local

humhub.env.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Use this file to pass HumHub Configuration
2+
3+
HUMHUB_DEBUG=false

image/Dockerfile

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
FROM debian:bookworm
2+
3+
ARG HUMHUB_GIT_BRANCH="develop"
4+
5+
RUN apt-get update && apt-get install -y \
6+
apache2 \
7+
php-fpm php php-cli \
8+
php-imagick php-curl php-bz2 php-gd php-intl php-mbstring php-mysql php-zip php-apcu php-xml php-ldap \
9+
unzip curl zip joe git npm \
10+
supervisor
11+
12+
#------------------------------------------------------------------------------------------------
13+
# PHP, Apache2, FPM Config
14+
#------------------------------------------------------------------------------------------------
15+
16+
RUN sed -i 's/variables_order = "GPCS"/variables_order = "EGPCS"/g' /etc/php/8.2/cli/php.ini && \
17+
sed -i 's/variables_order = "GPCS"/variables_order = "EGPCS"/g' /etc/php/8.2/fpm/php.ini && \
18+
sed -i 's/post_max_size = 8M/post_max_size = 512M/g' /etc/php/8.2/fpm/php.ini && \
19+
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 512M/g' /etc/php/8.2/fpm/php.ini && \
20+
sed -i 's/max_execution_time = 30/max_execution_time = 90/g' /etc/php/8.2/fpm/php.ini && \
21+
sed -i 's/memory_limit = 128M/memory_limit = 256M/g' /etc/php/8.2/fpm/php.ini && \
22+
a2enmod ssl rewrite headers proxy_fcgi setenvif proxy_fcgi && \
23+
a2enconf php8.2-fpm && \
24+
echo "Listen 8404" > /etc/apache2/ports.conf
25+
26+
COPY files/apache-config.conf /etc/apache2/sites-available/000-default.conf
27+
COPY files/php-fpm-www.conf /etc/php/8.2/fpm/pool.d/www.conf
28+
29+
EXPOSE 80
30+
31+
#------------------------------------------------------------------------------------------------
32+
# Install Requirements: Composer, NPM, Less, Grunt
33+
#------------------------------------------------------------------------------------------------
34+
35+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
36+
npm install -g grunt-cli less less-plugin-clean-css
37+
38+
#------------------------------------------------------------------------------------------------
39+
# HumHub Base GIT Install
40+
#------------------------------------------------------------------------------------------------
41+
42+
RUN mkdir -p /opt/humhub
43+
WORKDIR /opt/humhub
44+
45+
RUN git clone https://github.com/humhub/humhub.git /opt/humhub && \
46+
git config --global --add safe.directory /opt/humhub && \
47+
git checkout ${HUMHUB_GIT_BRANCH} && \
48+
composer install --no-interaction --optimize-autoloader --prefer-dist && \
49+
npm install && \
50+
grunt build-assets && \
51+
rm -rf /var/www/html/* && \
52+
mkdir -p /var/www/html/protected/runtime && \
53+
cp /opt/humhub/.htaccess.dist /var/www/html/.htaccess && \
54+
ln -s /var/lib/humhub/uploads/ /var/www/html/ && \
55+
ln -s /var/lib/humhub/assets/ /var/www/html/ && \
56+
ln -s /var/lib/humhub/themes/ /var/www/html/ && \
57+
ln -s /var/lib/humhub/config/ /var/www/html/protected/ && \
58+
ln -s /var/lib/humhub/modules/ /var/www/html/protected/ && \
59+
ln -s /var/lib/humhub/logs/ /var/www/html/protected/runtime/ && \
60+
ln -s /opt/humhub/protected/humhub /var/www/html/protected/ && \
61+
ln -s /opt/humhub/protected/vendor /var/www/html/protected/ && \
62+
ln -s /opt/humhub/static /var/www/html/ && \
63+
mkdir -p /var/lib/humhub-modules-custom && \
64+
rm -rf /opt/humhub/.git* && \
65+
rm -rf /opt/humhub/.idea && \
66+
rm -rf /opt/humhub/.editorconfig && \
67+
rm -rf /opt/humhub/.php-cs* && \
68+
rm -rf /opt/humhub/index-test.php && \
69+
rm -rf /opt/humhub/node_modules && \
70+
rm -rf /opt/humhub/LICENSE* && \
71+
rm -rf /opt/humhub/*.js && \
72+
rm -rf /opt/humhub/*.lock && \
73+
rm -rf /opt/humhub/*.json && \
74+
rm -rf /opt/humhub/*.md && \
75+
rm -rf /opt/humhub/*.dist && \
76+
rm -rf /opt/humhub/robots.txt && \
77+
rm -rf /root/.cache && \
78+
rm -rf /root/.npm && \
79+
rm -rf /var/lib/apt/lists/*
80+
81+
# We cannot symlink these entry scripts atm, since the DynamicConfig is otherwise loaded from /opt/humhub
82+
RUN cp /opt/humhub/protected/yii /var/www/html/protected/ && \
83+
cp /opt/humhub/index.php /var/www/html/index.php
84+
85+
#------------------------------------------------------------------------------------------------
86+
87+
COPY ["files/humhub-queue-listen.sh", "files/humhub-cron.sh", "files/humhub-startup.sh", "files/docker-entrypoint.sh", "/"]
88+
RUN chmod +x /humhub-queue-listen.sh && \
89+
chmod +x /humhub-startup.sh && \
90+
chmod +x /docker-entrypoint.sh && \
91+
mkdir -p /var/log/supervisord && \
92+
mkdir -p /var/run/supervisord
93+
94+
COPY files/supervisord.conf /etc
95+
96+
97+
#------------------------------------------------------------------------------------------------
98+
99+
ENV HUMHUB_CONFIG__COMPONENTS__URL_MANAGER__SHOW_SCRIPT_NAME=false
100+
ENV HUMHUB_CONFIG__COMPONENTS__URL_MANAGER__ENABLE_PRETTY_URL=true
101+
ENV HUMHUB_CONFIG__MODULES__INSTALLER__ENABLE_AUTO_SETUP=true
102+
ENV HUMHUB_CONFIG__MODULES__MARKETPLACE__MODULE_BLACKLIST='["updater"]'
103+
ENV HUMHUB_CONFIG__PARAMS__MODULE_AUTOLOAD_PATHS='["/var/lib/humhub/modules-custom"]'
104+
ENV HUMHUB_CONFIG__COMPONENTS__REQUEST__TRUSTED_HOSTS='["0.0.0.0/0"]'
105+
ENV HUMHUB_CONFIG__RUNTIME_PATH=/var/www/html/protected/runtime
106+
ENV HUMHUB_ALIASES__WEBROOT=/var/www/html
107+
ENV HUMHUB_ALIASES__APP=/var/www/html/protected
108+
ENV HUMHUB_ALIASES__CONFIG=/var/www/html/protected/config
109+
ENV HUMHUB_ALIASES__HUMHUB=/var/www/html/protected/humhub
110+
111+
CMD ["/docker-entrypoint.sh"]

image/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker build --build-arg HUMHUB_GIT_BRANCH=develop --tag humhub/humhub-dev:latest .

image/debug-shell.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
CONTAINER_IMAGE_NAME="humhub/humhub-dev"
4+
5+
# Find containers running with the specified image base name (ignoring the tag)
6+
CONTAINER_IDS=$(docker ps --format "{{.ID}} {{.Image}}" | grep -E "^.+ ${CONTAINER_IMAGE_NAME}(:.+)?$" | awk '{print $1}')
7+
8+
# Check if any containers are running with the specified image name
9+
if [ -z "$CONTAINER_IDS" ]; then
10+
echo "Error: No container running with image '${CONTAINER_IMAGE_NAME}'."
11+
exit 1
12+
fi
13+
14+
# Count the number of containers
15+
CONTAINER_COUNT=$(echo "$CONTAINER_IDS" | wc -l)
16+
17+
if [ "$CONTAINER_COUNT" -gt 1 ]; then
18+
echo "Error: Multiple containers are running with image '${CONTAINER_IMAGE_NAME}'."
19+
exit 1
20+
fi
21+
22+
# Exactly one container is running, execute the PHP script inside it
23+
CONTAINER_ID=$(echo "$CONTAINER_IDS" | head -n 1)
24+
25+
echo "Executing PHP script in container '${CONTAINER_ID}'..."
26+
docker exec -it "$CONTAINER_ID" /bin/bash

0 commit comments

Comments
 (0)