From bfdb8f150d874e2503c46762d9d4d7fdfdc09249 Mon Sep 17 00:00:00 2001 From: Xbird Date: Mon, 28 Mar 2022 18:16:35 +0200 Subject: [PATCH] work on dockerfile --- .gitlab-ci.yml | 22 ++++++++++++++++++++++ Dockerfile | 27 +++++++++++++++++++++++++++ start.sh | 6 ++++++ 3 files changed, 55 insertions(+) create mode 100644 Dockerfile create mode 100644 start.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0f46591..927d8a2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,6 +14,7 @@ stages: - SecurityChecker - CodingStandards - UnitTests + - publish security-checker: stage: SecurityChecker @@ -38,3 +39,24 @@ twig-lint: script: - twig-lint --version && twig-lint lint ./templates allow_failure: false + +publish: + stage: publish + image: docker:dind + services: + - docker:dind + only: + - main + variables: + DOCKER_DRIVER: overlay2 + registry_host: '' + registry_user: '' + registry_pass: '' + registry_img: '' + before_script: + - apk add jq + script: + - APP_VERSION=$(cat package.json | jq .version -r) + - docker login $registry_host -u $registry_user -p $registry_pass + - docker build -f ./Dockerfile -t $registry_host/$registry_img:$APP_VERSION . + - docker push $registry_host/$registry_img:$APP_VERSION \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2d40bfb --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM php:8-apache + +COPY . . + +ENV DATABASE_URL=localhost + +# Apk install +RUN apt update -y && apt install zip wget -y + +# Install pdo +RUN docker-php-ext-install pdo_mysql + +# Install composer +RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && php composer-setup.php && php -r "unlink('composer-setup.php');" && mv composer.phar /usr/local/bin/composer +RUN composer install -n --no-scripts +RUN chown -R www-data:www-data /var/www/html/var + +ENV APACHE_DOCUMENT_ROOT /var/www/html/public + +RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf +RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf + +RUN chmod +x start.sh + +WORKDIR /var/www/html + +ENTRYPOINT ["./start.sh"] \ No newline at end of file diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..c9ac166 --- /dev/null +++ b/start.sh @@ -0,0 +1,6 @@ +#!/bin/bash +php bin/console doctrine:migrations:migrate --no-interaction +php bin/console cache:clear +a2enmod rewrite +chown www-data:www-data ./public/uploads +/usr/sbin/apachectl -D FOREGROUND \ No newline at end of file