Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
shibafu528 committed Nov 30, 2023
1 parent c19f3e2 commit 4d99451
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
.git
.gitignore
.gitattributes
node_modules
vendor
64 changes: 64 additions & 0 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build container image

on: push

jobs:
build:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4

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

- uses: docker/metadata-action@v5
id: meta_foundation
with:
images: ghcr.io/tissue-foundation

- uses: docker/build-push-action@v5
with:
push: true
context: .
file: ./docker/production/foundation.dockerfile
tags: ${{ steps.meta_foundation.outputs.tags }}
labels: ${{ steps.meta_foundation.outputs.labels }}

- uses: docker/metadata-action@v5
id: meta_nginx
with:
images: ghcr.io/tissue-nginx

- uses: docker/build-push-action@v5
with:
push: true
context: .
file: ./docker/production/nginx.dockerfile
tags: ${{ steps.meta_nginx.outputs.tags }}
labels: ${{ steps.meta_nginx.outputs.labels }}
build-args: |
TISSUE_FOUNDATION_IMAGE_NAME=${{ steps.meta_foundation.outputs.tags }}
- uses: docker/metadata-action@v5
id: meta_php
with:
images: ghcr.io/tissue-php

- uses: docker/build-push-action@v5
with:
push: true
context: .
file: ./docker/production/php.dockerfile
tags: ${{ steps.meta_php.outputs.tags }}
labels: ${{ steps.meta_php.outputs.labels }}
build-args: |
TISSUE_FOUNDATION_IMAGE_NAME=${{ steps.meta_foundation.outputs.tags }}
12 changes: 12 additions & 0 deletions docker/production/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
php:
image: shibafu528/tissue-php
env_file: .env
nginx:
image: shibafu528/tissue-nginx
environment:
PHP_APP_HOST: php
ports:
- 4519:80
depends_on:
- php
18 changes: 18 additions & 0 deletions docker/production/default.conf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
server {
listen 80;
server_name _;

root /app/public;
index index.php index.html;

location / {
try_files $uri $uri/ /index.php$is_args$args;
}

location ~ \.php$ {
fastcgi_pass ${PHP_APP_HOST}:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
22 changes: 22 additions & 0 deletions docker/production/foundation.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM php:8.0.30-cli-bullseye as php

RUN apt-get update \
&& apt-get install -y git libpq-dev unzip libicu-dev \
&& docker-php-ext-install pdo_pgsql intl \
&& curl -sS https://getcomposer.org/installer | php \
&& mv composer.phar /usr/local/bin/composer \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app
COPY . /app

RUN composer install -n --no-dev --prefer-dist --optimize-autoloader

FROM node:16.20.2-bullseye

WORKDIR /app
COPY --from=php /app /app

RUN yarn install \
&& yarn run prod \
&& yarn run doc
9 changes: 9 additions & 0 deletions docker/production/nginx.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ARG TISSUE_FOUNDATION_IMAGE_NAME

FROM ${TISSUE_FOUNDATION_IMAGE_NAME} as foundation

FROM nginx:alpine

COPY ./docker/production/default.conf.template /etc/nginx/templates/

COPY --from=foundation /app/public /app/public
15 changes: 15 additions & 0 deletions docker/production/php.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ARG TISSUE_FOUNDATION_IMAGE_NAME

FROM ${TISSUE_FOUNDATION_IMAGE_NAME} as foundation

FROM php:8.0.30-fpm-bullseye

RUN apt-get update \
&& apt-get install -y --no-install-recommends libpq-dev libicu-dev \
&& docker-php-ext-install pdo_pgsql intl \
&& rm -rf /var/lib/apt/lists/*

COPY --from=foundation --chown=www-data:www-data /app /app

RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

0 comments on commit 4d99451

Please sign in to comment.