Skip to content
Draft
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
34 changes: 34 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Node.js / npm
/node_modules
/public/hot
/public/storage

# Assets
/public/js
/public/css

# PHP / Laravel
/bootstrap/cache/*.php
/storage/framework/views/*.php
/storage/*.key
/vendor

# Env
.env.backup
.env.ci
.env.local
.env.backup
.env.docker.example

# Tooling
.phpunit.result.cache
npm-debug.log
yarn-error.log

# IDEs
/.idea
/.vscode

# Docker
Dockerfile
docker-compose.yml
16 changes: 16 additions & 0 deletions .env.docker.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
APP_NAME=Cachent
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=https://cachent.test

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=database
DB_PORT=3306
DB_DATABASE=cachent
DB_USERNAME=cachent
DB_PASSWORD=cachent
46 changes: 46 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Release

on:
push:
tags:
- 'v*'

jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
name: Docker
steps:

- name: Checkout
uses: actions/checkout@v3

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

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

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
54 changes: 54 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
FROM php:8.2-fpm-alpine as base

WORKDIR /app

# Install Docker PHP Extension Installer
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

# Install required PHP extensions and tools
RUN install-php-extensions \
bcmath \
opcache \
pdo_mysql \
@composer

# Remove cache
RUN rm -rf /var/cache/apk/*

FROM base as composer_builder

COPY composer.json /app/composer.json
COPY composer.lock /app/composer.lock

RUN composer install --no-dev --no-scripts

FROM node:18-alpine3.17 as npm_install

WORKDIR /app

COPY . /app

RUN npm ci

RUN npm run build

FROM base as final

WORKDIR /app

ARG APP_VERSION
ENV APP_VERSION=${APP_VERSION}
ENV WEB_DOCUMENT_ROOT=/app/public

COPY . /app

COPY --from=npm_install /app/public/ /app/public
COPY --from=composer_builder /app/vendor /app/vendor

RUN ln -s /data/torrents /app/storage/app/torrents

RUN php artisan event:cache
RUN php artisan view:cache

EXPOSE 9000
CMD ["php-fpm"]
51 changes: 51 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
version: '3.9'

services:
app:
build:
context: .
dockerfile: Dockerfile
environment:
DB_CONNECTION: ${DB_CONNECTION}
DB_HOST: ${DB_HOST}
DB_DATABASE: ${DB_DATABASE}
DB_USERNAME: ${DB_USERNAME}
DB_PASSWORD: ${DB_PASSWORD}
tty: true
ports:
- '9000:9000'
volumes:
- .:/app
networks:
- cachent

caddy:
image: caddy:alpine
ports:
- '8000:80'
volumes:
- .:/app
- ./docker/Caddyfile:/etc/caddy/Caddyfile
networks:
- cachent

database:
image: mariadb
environment:
MARIADB_RANDOM_ROOT_PASSWORD: true
MYSQL_DATABASE: ${DB_DATABASE}
MYSQL_USERNAME: ${DB_USERNAME}
MYSQL_PASSWORD: ${DB_PASSWORD}
volumes:
- database:/var/lib/mysql
ports:
- '3306:3306'
networks:
- cachent

networks:
cachent:
driver: bridge

volumes:
database:
5 changes: 5 additions & 0 deletions docker/Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:80

root * /app/public
php_fastcgi app:9000
file_server