Skip to content

Commit

Permalink
ci: init docker
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-ritti committed Mar 14, 2024
1 parent cb8ccd2 commit ebeb493
Show file tree
Hide file tree
Showing 9 changed files with 207 additions and 6 deletions.
52 changes: 52 additions & 0 deletions .docker/Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
(caching) {
@static {
file
path *.css *.js *.ico *.gif *.jpg *.jpeg *.png *.svg *.woff
path /build/*
path /media/*
}
handle @static {
header Cache-Control "public, max-age=31536000, must-revalidate"
}
@nocache {
path /sitemap*
}
handle @nocache {
header Cache-Control "no-cache, no-store, must-revalidate"
}
}

:80 {
root * {$DOCUMENT_ROOT:/var/www/html/}

# Point all PHP requests to an upstream socket, served by php-fpm
php_fastcgi localhost:9000 {
trusted_proxies private_ranges
capture_stderr
}

# Enable logging
log {
output stderr
format console
level ERROR
}

log {
output discard
level INFO
}

file_server
push

# Enable gzip compression (and zstd)
encode zstd gzip

import caching
}

:2021 {
tls internal
metrics
}
18 changes: 18 additions & 0 deletions .docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

su -s /bin/bash -c "mkdir -p var/cache var/log var/sessions public/media" www-data
su -s /bin/bash -c "chmod -R 777 public/media" www-data
su -s /bin/bash -c "php bin/console doctrine:database:drop --force" www-data
su -s /bin/bash -c "php bin/console doctrine:database:create --if-not-exists" www-data
su -s /bin/bash -c "php bin/console doctrine:migrations:migrate -n" www-data
su -s /bin/bash -c "php bin/console sylius:fixtures:load default -n" www-data
su -s /bin/bash -c "php bin/console doctrine:query:sql \"UPDATE sylius_channel SET theme_name = 'agence-adeliom/sylius-tailwindcss-theme'\"" www-data
su -s /bin/bash -c "php bin/console cache:clear" www-data


if [ "${1}" = "-D" ]; then
# start supervisord and services
exec /usr/bin/supervisord -n -c /etc/supervisord.conf
else
exec "$@"
fi
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
install
etc
docs
node_modules
.git
.github
.ddev
tests
.idea
.cd .babelrc
.DS_Store
debug
2 changes: 1 addition & 1 deletion .github/workflows/code_quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- uses: actions/cache@v3
- uses: actions/cache@v4
id: cache-composer
with:
path: ${{ steps.composer-cache.outputs.dir }}
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: "Release"

on:
release:
types: [published]

jobs:
tests:
name: Release
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
# Fetch submodules
submodules: recursive

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

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

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: adeliom/sylius-tailwindcss-theme
tags: |
type=semver,pattern={{major}}.{{minor}}.{{patch}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
build-args: |
VERSION=${{ steps.meta.outputs.version }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion .github/workflows/sylius.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
run: 'echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT'
-
name: 'Composer - Set cache'
uses: actions/cache@v3
uses: actions/cache@v4
id: cache-composer
with:
path: '${{ steps.composer-cache.outputs.dir }}'
Expand Down
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM adeliom/php:8.2-caddy-node20

ARG SYLIUS_VERSION=1.12.0
ARG SYMFONY_VERSION=6.4

RUN apk add --update make

RUN mkdir -p /opt/sylius

COPY . /opt/sylius

RUN cd /opt/sylius && \
make install-docker -e SYLIUS_VERSION=$SYLIUS_VERSION SYMFONY_VERSION=$SYMFONY_VERSION

RUN cp -ra /opt/sylius/install/Application/. /var/www/html && \
rm -rf /opt/sylius && \
chown -R www-data:www-data /var/www/html

ENV DOCUMENT_ROOT=/var/www/html/public/

ENV PHP_INI_MEMORY_LIMIT=1G
ENV PHP_INI_OPCACHE_MEMORY_CONSUMPTION=1024
ENV PHP_INI_OPCACHE_INTERNED_STRINGS_BUFFER=256
ENV PHP_INI_OPCACHE_MAX_ACCELERATED_FILES=20000
ENV PHP_INI_OPCACHE_VALIDATE_TIMESTAMPS=0
ENV PHP_INI_REALPATH_CACHE_TTL=600


WORKDIR /var/www/html
EXPOSE 80

COPY .docker/Caddyfile /etc/caddy/Caddyfile
COPY .docker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
RUN chmod +x /usr/local/bin/docker-entrypoint
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,8 @@ install-sylius:
${CONSOLE} sylius:fixtures:load default -n
${MYSQL} db -e "UPDATE sylius_channel SET theme_name = 'agence-adeliom/sylius-tailwindcss-theme' WHERE id = 1"
${NPM} install
${NPM} install tailwindcss
${NPM} install daisyui
${NPM} install postcss-loader@^7.0.0 --save-dev
${NPM} install autoprefixer --save-dev
${NPM} install tailwindcss @fortawesome/fontawesome-free daisyui
${NPM} install postcss-loader@^7.0.0 autoprefixer --save-dev
${NPM} run build
${CONSOLE} cache:clear
echo 'Project installation completed successfully.'
Expand Down Expand Up @@ -150,6 +148,7 @@ NPM_CI=cd ./install/Application && npm


install-ci: sylius-ci ## Install Plugin on Sylius [SYLIUS_VERSION=1.12.13] [SYMFONY_VERSION=6.4]
install-docker: sylius-docker ## Install Plugin on Sylius [SYLIUS_VERSION=1.12.13] [SYMFONY_VERSION=6.4]
.PHONY: install

reset-ci: ## Remove dependencies
Expand All @@ -167,6 +166,7 @@ phpunit-ci: phpunit-configure phpunit-run ## Run PHPUnit
### ¯¯¯¯¯¯

sylius-ci: sylius-standard-ci update-dependencies-ci install-plugin-ci install-theme-ci install-sylius-ci
sylius-docker: sylius-standard-ci update-dependencies-ci install-plugin-ci install-theme-ci install-sylius-docker
.PHONY: sylius-ci

sylius-standard-ci:
Expand Down Expand Up @@ -207,12 +207,18 @@ install-sylius-ci:
${CONSOLE_CI} doctrine:database:create --if-not-exists
${CONSOLE_CI} doctrine:migrations:migrate -n
${CONSOLE_CI} sylius:fixtures:load default -n
${MYSQL} db -e "UPDATE sylius_channel SET theme_name = 'agence-adeliom/sylius-tailwindcss-theme' WHERE id = 1"
${NPM_CI} install
${NPM_CI} install tailwindcss @fortawesome/fontawesome-free daisyui
${NPM_CI} install postcss-loader@^7.0.0 autoprefixer --save-dev
${NPM_CI} run build
${CONSOLE_CI} cache:clear

install-sylius-docker:
${NPM_CI} install
${NPM_CI} install tailwindcss @fortawesome/fontawesome-free daisyui
${NPM_CI} install postcss-loader@^7.0.0 autoprefixer --save-dev
${NPM_CI} run build

phpunit-configure-ci:
cp phpunit.xml.dist ${TEST_DIRECTORY_CI}/phpunit.xml
Expand Down
26 changes: 26 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: sylius-tailwindcss-theme
services:
sylius:
build:
context: .
dockerfile: Dockerfile
image: sylius
environment:
APP_ENV: dev
DATABASE_URL: mysql://user:password@database:3306/mydatabase?serverVersion=10.11.7-MariaDB&charset=utf8mb4
ports:
- 80:80
database:
image: mariadb:10
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: mydatabase
MYSQL_USER: user
MYSQL_PASSWORD: password
volumes:
- data:/var/lib/mysql
ports:
- "3306:3306"

volumes:
data:

0 comments on commit ebeb493

Please sign in to comment.