Compare commits

...

3 Commits

Author SHA1 Message Date
Kacper Donat
77c7ce56ed Finish up moving to docker 2024-01-10 22:23:55 +01:00
Kacper Donat
d90286f741 Add consumer restart to deploy procedure 2020-04-14 20:06:23 +02:00
Kacper Donat
1fe93e74c2 Add deployer configuration 2020-04-14 18:48:41 +02:00
12 changed files with 170 additions and 51 deletions

16
.dockerignore Normal file
View File

@ -0,0 +1,16 @@
###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###
###> symfony/webpack-encore-bundle ###
/node_modules/
/public/build/
npm-debug.log
yarn-error.log
###< symfony/webpack-encore-bundle ###

2
.gitignore vendored
View File

@ -15,3 +15,5 @@
npm-debug.log
yarn-error.log
###< symfony/webpack-encore-bundle ###
/assets/fontawesome

59
Dockerfile Normal file
View File

@ -0,0 +1,59 @@
# syntax=docker/dockerfile:1
FROM node:12 as assets
WORKDIR /appsource
# First copy only dependencies related info for better caching
COPY package.json yarn.lock ./
COPY assets/fontawesome/fontawesome-pro-5.15.4-web assets/fontawesome/fontawesome-pro-5.15.4-web
RUN yarn
COPY . .
RUN yarn run build
FROM php:7.4-fpm-alpine
# Timezone
RUN ln -snf /usr/share/zoneinfo/Europe/Warsaw /etc/localtime
RUN echo "date.timezone = Europe/Warsaw" >> /usr/local/etc/php/conf.d/datetime.ini;
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
COPY --from=composer:1 /usr/bin/composer /usr/local/bin/
# Box
RUN wget https://github.com/humbug/box/releases/download/3.8.4/box.phar \
&& mv box.phar /usr/local/bin/box \
&& chmod +x /usr/local/bin/box
RUN install-php-extensions sockets redis zip curl;
ARG BUILD_MODE=prod
RUN set -eux; \
if [ "$BUILD_MODE" = "dev" ]; then \
install-php-extensions xdebug; \
{ \
echo "xdebug.discover_client_host=1"; \
echo "xdebug.mode=debug"; \
} > "$PHP_INI_DIR"/conf.d/90-xdebug.ini; \
elif [ "$BUILD_MODE" = "prod" ]; then \
install-php-extensions opcache; \
{ \
echo "opcache.enable_cli=1"; \
echo "opcache.max_accelerated_files=40000"; \
} > "$PHP_INI_DIR"/conf.d/90-opcache.ini; \
fi
WORKDIR /var/www
COPY composer.* ./
RUN composer install --no-dev --no-scripts --no-autoloader --prefer-dist --no-progress --no-interaction && \
composer check-platform-reqs
COPY . .
RUN composer dump-autoload --optimize && \
composer run-script post-install-cmd
COPY --link --from=assets /appsource/public/build ./public/build

View File

@ -24,6 +24,7 @@
"tightenco/collect": "^7.5"
},
"require-dev": {
"deployer/recipes": "^6.2"
},
"config": {
"preferred-install": {

62
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "ff5ad5d6a23af043f032470a0f69507e",
"content-hash": "5928d7deef12813659a9247a706c3061",
"packages": [
{
"name": "doctrine/annotations",
@ -4646,7 +4646,65 @@
"time": "2018-04-25T15:33:34+00:00"
}
],
"packages-dev": [],
"packages-dev": [
{
"name": "deployer/recipes",
"version": "6.2.2",
"source": {
"type": "git",
"url": "https://github.com/deployphp/recipes.git",
"reference": "84b3229c518c094a950e1fe785b7b8f9598770fe"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/deployphp/recipes/zipball/84b3229c518c094a950e1fe785b7b8f9598770fe",
"reference": "84b3229c518c094a950e1fe785b7b8f9598770fe",
"shasum": ""
},
"require": {
"php": "~7.0"
},
"replace": {
"deployer/recipes": "self.version"
},
"require-dev": {
"deployer/deployer": "^6.3"
},
"type": "library",
"autoload": {
"files": [
"autoload.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Anton Medvedev",
"email": "anton@medv.io"
}
],
"description": "3rd party deployer recipes",
"homepage": "https://github.com/deployphp/recipes",
"keywords": [
"cachetool",
"cloudflare",
"deploy",
"deployer",
"deployment",
"hipchat",
"newrelic",
"rabbit",
"recipes",
"sentry",
"slack",
"yarn"
],
"time": "2019-06-27T06:47:18+00:00"
}
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],

View File

@ -2,6 +2,8 @@
namespace Deployer;
require 'recipe/symfony4.php';
require './vendor/deployer/recipes/recipe/cachetool.php';
require './vendor/deployer/recipes/recipe/yarn.php';
// Project name
set('application', 'keylighter.kadet.net');
@ -10,7 +12,9 @@ set('application', 'keylighter.kadet.net');
set('repository', 'git@git.kadet.net:kadet.net/keylighter.git');
// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', true);
set('git_tty', true);
set('keep_releases', 3);
set('default_stage', 'production');
// Shared files/dirs between deploys
add('shared_files', []);
@ -22,16 +26,34 @@ add('writable_dirs', []);
// Hosts
host('kadet.net')
->stage('production')
->set('deploy_path', '~/www/{{application}}');
->set('deploy_path', '~/www/{{application}}')
;
localhost()
->roles('test', 'build')
->set('deploy_path', '/tmp/build/{{application}}')
->set('keep_releases', 1);
// Tasks
task('build', function () {
run('cd {{release_path}} && make');
task('assets:build', function () {
run('yarn install');
run('yarn build');
})->onRoles('build');
task('assets:upload', function () {
upload('public/build/', '{{release_path}}/public');
upload('public/img/', '{{release_path}}/public');
});
task('assets', ['assets:build', 'assets:upload']);
task('restart:consumer', 'systemctl --user restart keylighter-updater');
// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
after('deploy:symlink', 'cachetool:clear:opcache');
after('deploy:symlink', 'restart:consumer');
// Migrate database before symlink new release.
//before('deploy:symlink', 'database:migrate');
before('deploy:symlink', 'assets');

View File

@ -10,7 +10,7 @@ services:
- ./docker/nginx/keylighter.localhost:/etc/nginx/conf.d/keylighter.conf
php:
build: docker/php
build: .
environment:
- MESSENGER_TRANSPORT_DSN=redis://redis:6379/messages
env_file:

View File

@ -1 +0,0 @@
PHP_IDE_CONFIG=serverName=keylighter

View File

@ -1,39 +0,0 @@
FROM php:7.3-fpm
ARG XDEBUG_REMOTE_HOST="172.17.0.1"
RUN apt-get update && \
apt-get install -y --no-install-recommends git zip libzip-dev wget libcurl4-openssl-dev
RUN docker-php-ext-install zip curl
# XDebug
RUN pecl install xdebug-2.9.0 && docker-php-ext-enable xdebug
RUN echo "xdebug.remote_enable = 1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
echo "xdebug.remote_host = ${XDEBUG_REMOTE_HOST}" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini;
# Redis
RUN pecl install -o -f redis && docker-php-ext-enable redis
# Cleanup
RUN rm -rf /tmp/pear
# 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 \
&& chmod +x /usr/local/bin/composer
# Box
RUN wget https://github.com/humbug/box/releases/download/3.8.4/box.phar \
&& mv box.phar /usr/local/bin/box \
&& chmod +x /usr/local/bin/box
# Timezone
RUN ln -snf /usr/share/zoneinfo/Europe/Warsaw /etc/localtime
RUN echo "date.timezone = Europe/Warsaw" >> /usr/local/etc/php/conf.d/datetime.ini;
WORKDIR /var/www
EXPOSE 9001

View File

@ -1,2 +0,0 @@
php_admin_flag[log_errors] = on
php_flag[display_errors] = off

View File

@ -2,7 +2,7 @@
"devDependencies": {
"@babel/plugin-transform-react-jsx": "^7.9.4",
"@babel/preset-react": "^7.0.0",
"@fortawesome/fontawesome-pro": "^5.13.0",
"@fortawesome/fontawesome-pro": "file:assets/fontawesome/fontawesome-pro-5.15.4-web",
"@symfony/webpack-encore": "^0.28.2",
"@types/bootstrap": "^3.3.32",
"@types/jquery": "^2.0.41",

View File

@ -1,4 +1,7 @@
{
"deployer/recipes": {
"version": "6.2.2"
},
"doctrine/annotations": {
"version": "1.0",
"recipe": {