Skip to content

Commit

Permalink
Merge pull request #57 from fykosak/feature/docker-image
Browse files Browse the repository at this point in the history
Docker image
  • Loading branch information
sstenchlak authored Nov 21, 2023
2 parents db2ed7a + 2cc25ab commit 931868d
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 1 deletion.
34 changes: 34 additions & 0 deletions .github/workflows/deploy-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Create and publish a Docker image
on: push

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Compile Javascript and CSS
FROM node:latest AS node-builder
WORKDIR /usr/src/webs
COPY . .
RUN npm install && npm run build

# Install PHP dependencies and init translations
FROM composer as composer-builder
WORKDIR /usr/src/webs
COPY --from=node-builder /usr/src/webs /usr/src/webs
RUN composer install --no-dev --no-interaction --no-progress --optimize-autoloader --ignore-platform-reqs

# Prepare files for the final image
RUN mkdir /usr/src/final
RUN cp -r /usr/src/webs/app /usr/src/webs/www /usr/src/webs/vendor /usr/src/final/

# Final image
FROM php:8.2-apache
RUN apt-get update && apt install -y \
gettext \
locales \
&& docker-php-ext-configure gettext \
&& docker-php-ext-install \
gettext \
&& a2enmod rewrite \
&& sed -i -e 's/# cs_CZ.UTF-8/cs_CZ.UTF-8/' /etc/locale.gen \
&& sed -i -e 's/# en_US.UTF-8/en_US.UTF-8/' /etc/locale.gen \
&& dpkg-reconfigure --frontend=noninteractive locales

USER www-data
WORKDIR /var/www/webs
COPY --chown=www-data --from=composer-builder /usr/src/final /var/www/webs/
RUN ./app/i18n/compile.sh
6 changes: 5 additions & 1 deletion app/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ private static function boot(string $site): Configurator
->register();

$configurator->addConfig(__DIR__ . '/config/config.' . $site . '.neon');
$configurator->addConfig(__DIR__ . '/config/config.' . $site . '.local.neon');
if (getenv('NETTE_EXTERNAL_LOCAL_CONFIG') === '1') {
$configurator->addConfig(__DIR__ . '/config/local/config.' . $site . '.local.neon');
} else {
$configurator->addConfig(__DIR__ . '/config/config.' . $site . '.local.neon');
}

return $configurator;
}
Expand Down
6 changes: 6 additions & 0 deletions docker-compose-example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
config/app/*
!config/app/.gitkeep
log/*
!log/.gitkeep
temp/*
!temp/.gitkeep
Empty file.
31 changes: 31 additions & 0 deletions docker-compose-example/config/webs.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Directory /var/www/webs>
AllowOverride All
Require all granted
</Directory>

#SetEnv NETTE_DEVEL 1
SetEnv NETTE_EXTERNAL_LOCAL_CONFIG 1

<VirtualHost *:80>
ServerName online.fyziklani.cz.local
ServerAlias online.fyziklani.org.local
DocumentRoot /var/www/webs/www/fol
</VirtualHost>

<VirtualHost *:80>
ServerName fyziklani.cz.local
ServerAlias fyziklani.org.local
DocumentRoot /var/www/webs/www/fof
</VirtualHost>

<VirtualHost *:80>
ServerName dsef.cz.local
ServerAlias dsef.org.local
DocumentRoot /var/www/webs/www/dsef
</VirtualHost>

<VirtualHost *:80>
ServerName fykos.cz.local
ServerAlias fykos.org.local
DocumentRoot /var/www/webs/www/fykos
</VirtualHost>
16 changes: 16 additions & 0 deletions docker-compose-example/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: '3.5'
services:
app:
build: ..
ports:
- "8080:80"
user: "1000:1000"
volumes:
# Cache directory
- "./temp:/var/www/webs/temp/"
# Error logs
- "./log:/var/www/webs/log/"
# Apache configuration
- "./config/webs.conf:/etc/apache2/sites-enabled/000-default.conf"
# App configuration
- "./config/app:/var/www/webs/app/config/local/"
Empty file.
Empty file.

0 comments on commit 931868d

Please sign in to comment.