Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
williammck committed Oct 19, 2024
0 parents commit 725b194
Show file tree
Hide file tree
Showing 8 changed files with 819 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: push

on:
push:
branches:
- main

jobs:
push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Gather metadata
id: meta
uses: docker/metadata-action@v5
with:
images: registry.digitalocean.com/vatsim-containers/bmac
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha,priority=300,prefix=
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DigitalOcean Container Registry
uses: docker/login-action@v3
with:
registry: registry.digitalocean.com
username: ${{ secrets.DO_REGISTRY_USERNAME }}
password: ${{ secrets.DO_REGISTRY_USERNAME }}

- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
provenance: false
50 changes: 50 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
FROM unit:1.33.0-php8.3

ARG BMAC_TAG=v4.1.3

# Install PHP extensions
RUN set -ex \
&& apt-get update \
&& apt-get install --no-install-recommends -y git libfreetype6 libfreetype6-dev libjpeg62-turbo libjpeg62-turbo-dev libpng16-16 libpng-dev libwebp7 libwebp-dev libzip4 libzip-dev unzip \
&& docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \
&& docker-php-ext-install gd opcache pcntl pdo_mysql zip \
&& pecl install redis-6.0.2 \
&& docker-php-ext-enable redis \
&& apt-get purge -y --auto-remove git libfreetype6-dev libjpeg62-turbo-dev libpng-dev libwebp-dev libzip-dev \
&& rm -rf /tmp/pear /var/lib/apt/lists/*

# Install Composer
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer

# Configure PHP & Unit
COPY php.ini /usr/local/etc/php/php.ini
COPY bootstrap-laravel.sh /docker-entrypoint.d/
COPY unit.json /docker-entrypoint.d/

# Copy application files
WORKDIR /var/www/app
RUN set -ex \
&& curl -L https://github.com/daveroverts/bmac/archive/refs/tags/${BMAC_TAG}.tar.gz | tar -C /var/www/app --strip-components=1 -xz \
&& chown -R unit:unit /var/www/app

# Install Composer dependencies
RUN set -ex \
&& composer install --no-dev --optimize-autoloader \
&& rm -rf /root/.composer \
&& php artisan storage:link \
&& chown -R unit:unit bootstrap/cache public/storage vendor

# Build frontend assets
COPY favicon.ico /var/www/app/public/favicon.ico
COPY vatsim-logo.png /var/www/app/public/images/division-horizontal.png
COPY vatsim-logo.png /var/www/app/public/images/division-square.png
RUN set -ex \
&& apt-get update \
&& apt-get install --no-install-recommends -y build-essential git nodejs npm \
&& npm ci \
&& npm run build \
&& apt-get purge -y --auto-remove build-essential git nodejs npm \
&& rm -rf /root/.npm /var/lib/apt/lists/* /var/www/app/node_modules \
&& chown -R unit:unit public

# CMD and ENTRYPOINT are inherited from the Unit image
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions bootstrap-laravel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

set -eux

cd /var/www/app

# Cache/compile Laravel structs
/usr/local/bin/php artisan config:cache
/usr/local/bin/php artisan event:cache
/usr/local/bin/php artisan livewire:discover
/usr/local/bin/php artisan route:cache
/usr/local/bin/php artisan view:cache
/bin/chown -R unit:unit bootstrap/cache storage/framework/views
Binary file added favicon.ico
Binary file not shown.
22 changes: 22 additions & 0 deletions php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[PHP]
display_errors = Off
display_startup_errors = Off
enable_dl = Off
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
expose_php = Off
log_errors = On
max_execution_time = 30
output_buffering = 4096
register_argc_argv = Off
request_order = "GP"
short_open_tag = Off
variables_order = "GPCS"

[date]
date.timezone = "UTC"

[opcache]
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=7963
opcache.memory_consumption=256
opcache.validate_timestamps=0
34 changes: 34 additions & 0 deletions unit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"listeners": {
"*:80": {
"pass": "routes"
}
},

"routes": [
{
"match": {
"uri": "!/index.php"
},
"action": {
"share": "/var/www/app/public$uri",
"fallback": {
"pass": "applications/laravel"
}
}
}
],

"applications": {
"laravel": {
"type": "php",
"limits": {
"requests": 1000
},
"root": "/var/www/app/public/",
"script": "index.php"
}
},

"access_log": "/dev/stdout"
}
Binary file added vatsim-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 725b194

Please sign in to comment.