Skip to content

Commit

Permalink
Build .tar.gz file in docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
Daanvm committed Oct 12, 2024
1 parent 5c09cba commit 30e8c85
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 149 deletions.
18 changes: 6 additions & 12 deletions .github/workflows/deploy-strato.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,12 @@ jobs:
- name: Checkout master
uses: actions/checkout@v3

- name: Install dependencies
uses: php-actions/composer@v6
with:
php_version: "8.1"
php_extensions: pcntl imagick
version: latest
working_dir: app

# TODO: rename from warmup to build, it's no longer a warmup now.
- name: Run warmup script
run: ${GITHUB_WORKSPACE}/app/scripts/christelmusic warmup
shell: bash
- name: Build .tar.gz file
run: |
docker build --tag local-img/zipper --target zipper .
docker create --name zipper local-img/zipper
docker cp zipper:/build.tar.gz ./build.tar.gz
docker rm -f zipper
# TODO: remove debug
- name: Debug print all files
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile-php
file: ./Dockerfile
push: true
tags: daanvm/christelmusic.nl-php:latest
cache-from: type=gha
Expand Down
28 changes: 19 additions & 9 deletions Dockerfile-php → Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
FROM php:8.2-fpm-alpine as base
FROM php:8.1-apache as base

# Use the default production configuration
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

COPY app /var/www/html

FROM base as builder

# Install php dependencies
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN chmod uga+x /usr/local/bin/install-php-extensions && sync && \
install-php-extensions imagick pcntl

FROM base as builder
install-php-extensions imagick pcntl zip

# Install composer dependencies
COPY --from=composer /usr/bin/composer /usr/bin/composer
COPY app/composer.* /usr/src/build/
WORKDIR /usr/src/build
WORKDIR /var/www/html
RUN composer install

# Create cache
RUN /var/www/html/scripts/christelmusic warmup

FROM builder as zipper

RUN tar -czvf /build.tar.gz /var/www/html/*

FROM base

COPY app /usr/src/christelmusic.nl
COPY --from=builder /usr/src/build/vendor /usr/src/christelmusic.nl/vendor
RUN /usr/src/christelmusic.nl/scripts/christelmusic warmup
WORKDIR /usr/src/christelmusic.nl
RUN a2enmod rewrite

COPY --from=builder /var/www/html/vendor /var/www/html/vendor
COPY --from=builder /var/www/html/cache /var/www/html/cache
9 changes: 0 additions & 9 deletions Dockerfile-nginx

This file was deleted.

2 changes: 2 additions & 0 deletions app/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
RewriteEngine on
RewriteRule ^(.*)$ public/$1 [QSA,L]
11 changes: 11 additions & 0 deletions app/public/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Options -Indexes

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?PARABLE_REDIRECT_URL=$1 [QSA,L]

RewriteCond %{HTTPS} off
RewriteRule .* - [E=REQUEST_SCHEME:http]

RewriteCond %{HTTPS} on
RewriteRule .* - [E=REQUEST_SCHEME:https]
81 changes: 0 additions & 81 deletions christelmusic.nl.yaml

This file was deleted.

22 changes: 0 additions & 22 deletions config/nginx/conf.d/default.conf

This file was deleted.

23 changes: 8 additions & 15 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,26 @@
---
version: '3.9'
services:
christelmusic-nl-nginx:
christelmusic-nl:
build:
dockerfile: Dockerfile-nginx
restart: unless-stopped
volumes:
- ./app/public:/usr/share/nginx/html/:delegated
ports:
- '8081:80'

christelmusic-nl-php:
build:
dockerfile: Dockerfile-php
dockerfile: Dockerfile
restart: unless-stopped
env_file:
- .env.local
volumes:
- ./app:/usr/src/christelmusic.nl/:delegated
- ./app:/var/www/html:delegated
ports:
- '8081:80'

composer-build:
build:
dockerfile: Dockerfile-php
dockerfile: Dockerfile
target: builder
volumes:
- ./app:/usr/src/build/:delegated
- ./app:/var/www/html:delegated
command:
- /bin/sh
- -c
- |
composer install
/usr/src/build/scripts/christelmusic warmup
/var/www/html/scripts/christelmusic warmup

0 comments on commit 30e8c85

Please sign in to comment.