Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Crinisus committed Mar 24, 2024
0 parents commit ee9b3e5
Show file tree
Hide file tree
Showing 271 changed files with 22,342 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.git
/.github
905 changes: 905 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Force LF line ending on shell scripts
Dockerfile text eol=lf
*.cnf text eol=lf
*.sh text eol=lf
*.yml text eol=lf
*.yaml text eol=lf
*.json text eol=lf

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
78 changes: 78 additions & 0 deletions .github/workflows/test-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Test and Deploy

on: [ push, pull_request, workflow_dispatch ]

jobs:
build:
name: Build and Test
runs-on: self-hosted
steps:
- uses: actions/checkout@master

- name: Cache PHP dependencies
uses: actions/cache@v4
with:
path: www/vendor
key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }}

- name: Run Composer install
run: |
composer install --no-interaction --ignore-platform-reqs
composer require staabm/annotate-pull-request-from-checkstyle
- name : Run PHP Linter
run : |
vendor/bin/parallel-lint . --exclude vendor --checkstyle | vendor/bin/cs2pr
- name : Run PHPStan
run : |
vendor/bin/phpstan analyze --error-format=checkstyle | vendor/bin/cs2pr
- name : Run PHP Code Sniffer
run : |
vendor/bin/phpcs --report=checkstyle | vendor/bin/cs2pr
publish:
name: Publish
needs: build
runs-on: self-hosted
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@master

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Docker Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/waterwolfdev/waterwolf-site
tags: |
type=ref,event=branch
- name: Debug Docker Metadata
run: |
echo "Tags: ${{ steps.meta.outputs.tags }}"
echo "GitHub Ref: ${{ github.ref }}"
echo "Default Branch: ${{ github.event.repository.default_branch }}"
echo "GitHub Event Name: ${{ github.event_name }}"
- name: Publish to Docker Image Repo
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/waterwolfdev/waterwolf-site:buildcache,mode=max
cache-to: type=registry,ref=ghcr.io/waterwolfdev/waterwolf-site:buildcache,mode=max
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Compiled Code
/web/static/dist/*

# User Uploaded Content
/web/media/*

# Local Dev/Editors
/build/dev/db_full.sql
/.idea
/dev.env
/docker-compose.override.yml

# Packages
/vendor/*
/node_modules/*
8 changes: 8 additions & 0 deletions .phplint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
path: ./
jobs: 10
cache: ../www_tmp/phplint.cache
extensions:
- php
- phtml
exclude:
- vendor
13 changes: 13 additions & 0 deletions .phpstorm.meta.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace PHPSTORM_META {

override(
\Psr\Container\ContainerInterface::get(0),
map(
[
'' => '@',
]
)
);
}
90 changes: 90 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#
# Base build (common steps)
#
FROM php:8.3-fpm-alpine3.19 AS base

ENV TZ=UTC

COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

RUN install-php-extensions @composer gd curl xml zip mbstring pdo_mysql apcu

RUN apk add --no-cache zip git curl bash \
supervisor \
caddy \
nodejs npm \
supercronic \
su-exec

# Set up App user
RUN mkdir -p /var/app/www \
&& addgroup -g 1000 app \
&& adduser -u 1000 -G app -h /var/app/ -s /bin/sh -D app \
&& addgroup app www-data \
&& mkdir -p /var/app/media /var/app/www /var/app/www_tmp /run/supervisord /logs \
&& chown -R app:app /var/app /logs

COPY --chown=app:app ./build/scripts/ /usr/local/bin
RUN chmod a+x /usr/local/bin/*

COPY ./build/supervisord.conf /etc/supervisord.conf
COPY ./build/services/ /etc/supervisor.d/

COPY --chown=app:app ./build/cron /etc/cron.d/app

COPY ./build/phpfpmpool.conf /usr/local/etc/php-fpm.d/www.conf
COPY ./build/php.ini /usr/local/etc/php/php.ini

VOLUME ["/var/app/www_tmp"]
VOLUME ["/var/app/media"]

EXPOSE 8080

WORKDIR /var/app/www

COPY --chown=app:app . .

#
# Development Build
#
FROM base AS development

COPY ./build/dev/services/ /etc/supervisor.d/
COPY ./build/dev/Caddyfile /etc/Caddyfile
COPY ./build/dev/entrypoint.sh /var/app/entrypoint.sh

RUN chmod a+x /var/app/entrypoint.sh

USER root

ENV APPLICATION_ENV=development

ENTRYPOINT ["/var/app/entrypoint.sh"]
CMD ["supervisord", "-c", "/etc/supervisord.conf"]

#
# Production Build
#
FROM base AS production

COPY ./build/prod/Caddyfile /etc/Caddyfile
COPY ./build/prod/entrypoint.sh /var/app/entrypoint.sh

RUN chmod a+x /var/app/entrypoint.sh

USER app

RUN composer install --no-dev --no-ansi --no-autoloader --no-interaction \
&& composer dump-autoload --optimize --classmap-authoritative \
&& composer clear-cache

RUN npm ci --include=dev \
&& npm run build \
&& npm cache clean --force

USER root

ENV APPLICATION_ENV=production

ENTRYPOINT ["/var/app/entrypoint.sh"]
CMD ["supervisord", "-c", "/etc/supervisord.conf"]
Loading

0 comments on commit ee9b3e5

Please sign in to comment.