Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The docker image demo is already available. #975

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 12 additions & 17 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
APP_NAME=Cypht

DB_CONNECTION_TYPE=host
DB_DRIVER=mysql
DB_CONNECTION_TYPE=socket
DB_DRIVER=sqlite
DB_PORT=
DB_HOST=localhost
DB_NAME=test
DB_USER=test
DB_PASS=123456
DB_SOCKET=/var/lib/mysqld/mysqld.sock
DB_NAME=cypht_test
DB_NAME=cypht_test
DB_PASS=cypht_test
DB_SOCKET=/var/lib/hm3/cypht.sqlite

SESSION_TYPE=PHP
AUTH_TYPE=DB
Expand All @@ -24,13 +24,11 @@ DEFAULT_SMTP_PORT=
DEFAULT_SMTP_TLS=
DEFAULT_SMTP_NO_AUTH=

USER_CONFIG_TYPE=file
USER_CONFIG_TYPE=DB
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one small request - can you leave the old version of the example env file? Most people would probably run fine with file configs rather than setting up a db for cypht.

USER_SETTINGS_DIR=/var/lib/hm3/users
ATTACHMENT_DIR=/var/lib/hm3/attachments
APP_DATA_DIR=/var/lib/hm3/app_data

DISABLE_ORIGIN_CHECK=false

ADMIN_USERS=

COOKIE_DOMAIN=
Expand All @@ -51,14 +49,14 @@ CSS_COMPRESS=false
ALLOW_SESSION_CACHE=false
CACHE_CLASS=

ENABLE_REDIS=true
ENABLE_REDIS=false
REDIS_SERVER='127.0.0.1'
REDIS_PORT=6379
REDIS_INDEX=1
REDIS_PASS=
REDIS_SOCKET=/var/run/redis/redis-server.sock

ENABLE_MEMCACHED=true
ENABLE_MEMCACHED=false
MEMCACHED_SERVER='127.0.0.1'
MEMCACHED_PORT=11211
MEMCACHED_AUTH=false
Expand All @@ -71,11 +69,8 @@ LONG_SESSION_LIFETIME=30
ENCRYPT_AJAX_REQUESTS=
ENCRYPT_LOCAL_STORAGE=

ENCRYPT_LOCAL_STORAGE=

DISABLE_IP_CHECK=false

DISABLE_ORIGIN_CHECK=true
DISABLE_ORIGIN_CHECK=false

ALLOW_EXTERNAL_IMAGE_SOURCES=true

Expand Down Expand Up @@ -147,7 +142,7 @@ GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_REDIRECT_URI=
GITHUB_AUTH_URL=https://github.com/login/oauth/authorize
GITHUB_AUTH_URL=https://github.com/login/oauth/access_token
# GITHUB_AUTH_URL=https://github.com/login/oauth/access_token

#gmail
GMAIL_CLIENT_ID=
Expand All @@ -157,7 +152,7 @@ GMAIL_AUTH_URI=https://accounts.google.com/o/oauth2/auth
GMAIL_TOKEN_URI=https://www.googleapis.com/oauth2/v3/token
GMAIL_REFRESH_URI=https://www.googleapis.com/oauth2/v3/token

#aoutlook
#outlook
OUTLOOK_CLIENT_ID=
OUTLOOK_CLIENT_SECRET=
OUTLOOK_CLIENT_URI=
Expand Down
44 changes: 44 additions & 0 deletions .github/docker/cypht_setup_database.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
$connected = false;
$session_type = CYPHT_SESSION_TYPE;
$auth_type = CYPHT_AUTH_TYPE;
$user_config_type = CYPHT_USER_CONFIG_TYPE;
$db_driver = CYPHT_DB_DRIVER;
while(!$connected) {
try{
$conn = new pdo('CYPHT_DB_DRIVER:host=CYPHT_DB_HOST;dbname=CYPHT_DB_NAME', 'CYPHT_DB_USER', 'CYPHT_DB_PASS');
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
printf("Database connection successful ...\n");
$connected = true;
} catch(PDOException $e){
error_log('Waiting for database connection ... (' . $e->getMessage() . ')');
sleep(1);
}
}
if ($session_type == 'DB') {
if ($db_driver == 'mysql') {
$stmt = "CREATE TABLE IF NOT EXISTS hm_user_session (hm_id varchar(250), data longblob, date timestamp, primary key (hm_id));";
} elseif ($db_driver == 'pgsql') {
$stmt = "CREATE TABLE IF NOT EXISTS hm_user_session (hm_id varchar(250) primary key not null, data text, date timestamp);";
}
printf("Creating database table hm_user_session ...\n");
$conn->exec($stmt);
}
if ($auth_type == 'DB') {
if ($db_driver == 'mysql') {
$stmt = "CREATE TABLE IF NOT EXISTS hm_user (username varchar(250), hash varchar(250), primary key (username));";
} elseif ($db_driver == 'pgsql') {
$stmt = "CREATE TABLE IF NOT EXISTS hm_user (username varchar(255) primary key not null, hash varchar(255));";
}
printf("Creating database table hm_user ...\n");
$conn->exec($stmt);
}
if ($user_config_type == 'DB') {
if ($db_driver == 'mysql') {
$stmt = "CREATE TABLE IF NOT EXISTS hm_user_settings(username varchar(250), settings longblob, primary key (username));";
} elseif ($db_driver == 'pgsql') {
$stmt = "CREATE TABLE IF NOT EXISTS hm_user_settings (username varchar(250) primary key not null, settings text);";
}
printf("Creating database table hm_user_settings ...\n");
$conn->exec($stmt);
}
315 changes: 315 additions & 0 deletions .github/docker/docker-entrypoint.sh

Large diffs are not rendered by default.

81 changes: 81 additions & 0 deletions .github/docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
user www-data;
pid /run/nginx.pid;
worker_processes auto;
worker_rlimit_nofile 65535;
events {
multi_accept on;
worker_connections 65535;
}
http {
charset utf-8;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
log_not_found off;
types_hash_max_size 2048;
types_hash_bucket_size 64;
client_max_body_size 100M;
include mime.types;
default_type application/octet-stream;
access_log off;
error_log /dev/null;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;
ssl_protocols TLSv1.3;
ssl_stapling on;
ssl_stapling_verify on;
server {
listen 80;
listen [::]:80;
set $base /var/www;
root $base;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# favicon.ico
location = /favicon.ico {
log_not_found off;
}
# robots.txt
location = /robots.txt {
log_not_found off;
}
# assets, media
location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
expires 7d;
}
# svg, fonts
location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
add_header Access-Control-Allow-Origin "*";
expires 7d;
}
# gzip
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
location ~ [^/]\.php(/|$) {
fastcgi_pass 127.0.0.1:9000;
# split path
fastcgi_split_path_info ^(.+\.php)(/.+)$;
set $_fastcgi_path_info $fastcgi_path_info;
# 404
try_files $fastcgi_script_name =404;
# default fastcgi_params
include fastcgi_params;
# fastcgi settings
fastcgi_index index.php;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
# fastcgi params
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param PATH_INFO $_fastcgi_path_info;
fastcgi_param PHP_ADMIN_VALUE "open_basedir=$base/:/usr/lib/php/:/tmp/:/var/lib/hm3";
}
}
}
23 changes: 23 additions & 0 deletions .github/docker/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[supervisord]
user=root
nodaemon=true
logfile=/var/log/supervisord.log
pidfile=/var/run/supervisord.pid

[program:nginx]
command=/usr/sbin/nginx -g "daemon off;"
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

[program:php-fpm]
command=php-fpm
autostart=true
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
11 changes: 5 additions & 6 deletions .github/tests/.env
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ DB_SOCKET=/var/lib/mysqld/mysqld.sock

SESSION_TYPE=PHP
AUTH_TYPE=IMAP
LDAP_AUTH_SERVER=localhost
LDAP_AUTH_PORT=389
LDAP_AUTH_TLS=
LDAP_AUTH_BASE_DN=example,dc=com

IMAP_AUTH_NAME=localhost
IMAP_AUTH_SERVER=localhost
Expand Down Expand Up @@ -74,7 +70,6 @@ ENCRYPT_AJAX_REQUESTS=
ENCRYPT_LOCAL_STORAGE=

DISABLE_IP_CHECK=false

DISABLE_ORIGIN_CHECK=false

ALLOW_EXTERNAL_IMAGE_SOURCES=true
Expand Down Expand Up @@ -129,7 +124,6 @@ DEFAULT_SETTING_INLINE_MESSAGE=false
DEFAULT_SETTING_ENABLE_KEYBOARD_SHORTCUTS=1
DEFAULT_SETTING_ENABLE_SIEVE_FILTER=false


APP_2FA_SECRET=""
APP_2FA_SIMPLE=false

Expand Down Expand Up @@ -176,6 +170,11 @@ LDAP_USER=''
LDAP_PASS=''
LDAP_READ_WRITE=true

LDAP_AUTH_SERVER=localhost
LDAP_AUTH_PORT=389
LDAP_AUTH_TLS=
LDAP_AUTH_BASE_DN=example,dc=com

#WordPress
WORDPRESS_CLIENT_ID=
WORDPRESS_CLIENT_SECRET=
Expand Down
67 changes: 58 additions & 9 deletions .github/workflows/Nightly-Image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,73 @@ defaults:
shell: bash

on:
# push:
# branches:
# - master
# - dev

# pull_request:
# branches:
# - master
# - dev

workflow_call:
# workflow_dispatch:

# concurrency:
# group: build-nightly
# cancel-in-progress: true

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
Nightly-Image-Build:
name: Nightly-Image-${{ matrix.arch }}-PHP${{ matrix.php-versions }}
name: Nightly-Image
runs-on: ubuntu-latest

strategy:
matrix:
php-versions: ['7.4']
arch: ['x64', 'aarch64']
permissions:
contents: read
packages: write

steps:
- name: "Checkout code"
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: "Build Nightly Image"
run: |
echo "Publish each updated content to the nightly mirror, package and fix errors in time."
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=nightly,enable=true


- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
provenance: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

4 changes: 4 additions & 0 deletions .github/workflows/Test-Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ on:

workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
Test-phpunit:
name: PHPUNIT (PHP-${{ matrix.php-versions }} && DB-${{ matrix.database }})
Expand Down
Loading