Skip to content

Commit

Permalink
Add pre-commit and fix syntax problems
Browse files Browse the repository at this point in the history
  • Loading branch information
alufers committed Aug 30, 2023
1 parent 7ddfde6 commit bf5745e
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
permissions:
contents: read
packages: write
#
#
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand Down
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-json
- id: detect-private-key
- id: fix-encoding-pragma
- id: check-merge-conflict
- id: check-added-large-files
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.32.0
hooks:
- id: yamllint
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.35.0
hooks:
- id: markdownlint-fix
- id: markdownlint
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.9.0
hooks:
- id: shellcheck

12 changes: 12 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
extends: default
yaml-files:
- "*.yaml"
- "*.yml"
- ".yamllint"
rules:
line-length: disable
document-start: disable
truthy: disable
brackets: disable
comments: disable
colons: disable
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ ARG PHORGE_SHA=98dfac53ba721467a32b96641f3a18d428fb5441
ARG ARCANIST_SHA=788098096e113f34f0fafef23e4d16a2e80d64ca


ENV GIT_USER=git
ENV GIT_USER=git
ENV MYSQL_PORT=3306
ENV PROTOCOL=http


EXPOSE 80 443

# TODO: Once Phorge is updated to support PHP 8.0,
# TODO: Once Phorge is updated to support PHP 8.0,
# we can use PHP from debian repo instead of sury.org

RUN apt-get update -y && apt-get install -y wget lsb-release && \
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# README

Dockerfile for running Phorge in a container. Based on: https://github.com/cooperspencer/phorge
Dockerfile for running Phorge in a container. Based on: <https://github.com/cooperspencer/phorge>

## Differences from the original Dockerfile

- Use debian 12 (bookworm)
- Remove ssh server support
- Fetch Phorge commits by sha instead of downloading the latest one at build time
- Add mysql configuration as per Phorge suggestions

2 changes: 1 addition & 1 deletion configs/php.ini
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ zend.enable_gc = On

; Allows to include or exclude arguments from stack traces generated for exceptions
; Default: Off
; In production, it is recommended to turn this setting on to prohibit the output
; In production, it is recommended to turn this setting on to prohibit the output
; of sensitive information in stack traces
zend.exception_ignore_args = On

Expand Down
49 changes: 26 additions & 23 deletions scripts/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ set -e
if id "$GIT_USER" >/dev/null 2>&1; then
echo "user $GIT_USER already exists"
else
useradd $GIT_USER
usermod -p NP $GIT_USER
useradd "$GIT_USER"
usermod -p NP "$GIT_USER"
echo "$GIT_USER ALL=(daemon) SETENV: NOPASSWD: /bin/ls, /usr/bin/git, /usr/bin/git-upload-pack, /usr/bin/git-receive-pack, /usr/bin/ssh" >> /etc/sudoers
chown -R $GIT_USER /var/repo
/var/www/phorge/phorge/bin/config set phd.user $GIT_USER
/var/www/phorge/phorge/bin/config set diffusion.ssh-user $GIT_USER
chown -R "$GIT_USER" /var/repo
/var/www/phorge/phorge/bin/config set phd.user "$GIT_USER"
/var/www/phorge/phorge/bin/config set diffusion.ssh-user "$GIT_USER"
fi


/var/www/phorge/phorge/bin/config set files.enable-imagemagick true
#DB configuration
/var/www/phorge/phorge/bin/config set mysql.host $MYSQL_HOST
/var/www/phorge/phorge/bin/config set mysql.port $MYSQL_PORT
/var/www/phorge/phorge/bin/config set mysql.user $MYSQL_USER
/var/www/phorge/phorge/bin/config set mysql.host "$MYSQL_HOST"
/var/www/phorge/phorge/bin/config set mysql.port "$MYSQL_PORT"
/var/www/phorge/phorge/bin/config set mysql.user "$MYSQL_USER"

# if MYSQL_PASSWORD is empty, use check MYSQL_PASSWORD_FILE
if [ -z "$MYSQL_PASSWORD" ]
Expand All @@ -29,43 +29,46 @@ then
echo "MYSQL_PASSWORD or MYSQL_PASSWORD_FILE must be set"
exit 1
else
MYSQL_PASSWORD=$(cat $MYSQL_PASSWORD_FILE)
MYSQL_PASSWORD=$(cat "$MYSQL_PASSWORD_FILE")
fi
fi

/var/www/phorge/phorge/bin/config set mysql.pass $MYSQL_PASSWORD
/var/www/phorge/phorge/bin/config set mysql.pass "$MYSQL_PASSWORD"
/var/www/phorge/phorge/bin/config set diffusion.allow-http-auth true

if [ "$PROTOCOL" == "https" ]
then

# We want to output PHP
# shellcheck disable=SC2016
echo '<?php
$_SERVER['"'"'HTTPS'"'"'] = true;' > /var/www/phorge/phorge/support/preamble.php
fi

#Large file storage configuration
if [ ! -z "$MINIO_SERVER" ]
if [ -n "$MINIO_SERVER" ]
then
/var/www/phorge/phorge/bin/config set storage.s3.bucket $MINIO_BUCKET
if [ ! -z "$MINIO_SERVER_SECRET_KEY_FILE" ]
/var/www/phorge/phorge/bin/config set storage.s3.bucket "$MINIO_BUCKET"
if [ -n "$MINIO_SERVER_SECRET_KEY_FILE" ]
then
MINIO_SERVER_SECRET_KEY=$(cat $MINIO_SERVER_SECRET_KEY_FILE)
MINIO_SERVER_SECRET_KEY=$(cat "$MINIO_SERVER_SECRET_KEY_FILE")
fi
if [ ! -z "$MINIO_SERVER_ACCESS_KEY_FILE" ]
then`aa`
MINIO_SERVER_ACCESS_KEY=$(cat $MINIO_SERVER_ACCESS_KEY_FILE)
if [ -n "$MINIO_SERVER_ACCESS_KEY_FILE" ]
then
MINIO_SERVER_ACCESS_KEY=$(cat "$MINIO_SERVER_ACCESS_KEY_FILE")
fi
/var/www/phorge/phorge/bin/config set amazon-s3.secret-key $MINIO_SERVER_SECRET_KEY
/var/www/phorge/phorge/bin/config set amazon-s3.access-key $MINIO_SERVER_ACCESS_KEY
/var/www/phorge/phorge/bin/config set amazon-s3.endpoint $MINIO_SERVER:$MINIO_PORT
/var/www/phorge/phorge/bin/config set amazon-s3.secret-key "$MINIO_SERVER_SECRET_KEY"
/var/www/phorge/phorge/bin/config set amazon-s3.access-key "$MINIO_SERVER_ACCESS_KEY"
/var/www/phorge/phorge/bin/config set amazon-s3.endpoint "$MINIO_SERVER:$MINIO_PORT"
# /var/www/phorge/phorge/bin/config set amazon-s3.region us-west-1
fi

if [ ! -z "$MAILERS_CONFIG_FILE" ]
if [ -n "$MAILERS_CONFIG_FILE" ]
then
/var/www/phorge/phorge/bin/config set cluster.mailers --stdin < $MAILERS_CONFIG_FILE
/var/www/phorge/phorge/bin/config set cluster.mailers --stdin < "$MAILERS_CONFIG_FILE"
else
if [ ! -z "$SMTP_SERVER" ] && [ ! -z "$SMTP_PORT" ] && [ ! -z "$SMTP_USER" ] && [ ! -z "$SMTP_PASSWORD" ] && [ ! -z "$SMTP_PROTOCOL" ]
if [ -n "$SMTP_SERVER" ] && [ -n "$SMTP_PORT" ] && [ -n "$SMTP_USER" ] && [ -n "$SMTP_PASSWORD" ] && [ -n "$SMTP_PROTOCOL" ]
then
echo "[
{
Expand Down

0 comments on commit bf5745e

Please sign in to comment.