Skip to content

Commit

Permalink
Add deployment files
Browse files Browse the repository at this point in the history
  • Loading branch information
wachterjohannes authored and niklasnatter committed Oct 24, 2019
1 parent 4f87f27 commit 478b761
Show file tree
Hide file tree
Showing 52 changed files with 34,105 additions and 290 deletions.
5 changes: 2 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.git
vendor
public/build
public/website/build
public/build/admin
node_modules
tests
var
var
16 changes: 16 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,19 @@ SULU_ADMIN_EMAIL=

###> doctrine/phpcr-bundle ###
###< doctrine/phpcr-bundle ###

S3_KEY=
S3_SECRET=
S3_REGION=
S3_ENDPOINT=
S3_BUCKET_NAME=
S3_PATH_PREFIX=
SENTRY_DSN=
REDIS_HOST=
REDIS_PASSWORD=
VARNISH_SERVER=
PHPCR_BACKEND=doctrinedbal
PHPCR_BACKEND_URL=http://127.0.0.1:8080/server
###> sentry/sentry-symfony ###
SENTRY_DSN=
###< sentry/sentry-symfony ###
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@

# composer
/composer.phar
composer.lock
/vendor

# npm
package-lock.json
node_modules

# phpunit
Expand Down
65 changes: 65 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ stages:
- install
- test
- build
- deploy

composer:
stage: install
Expand All @@ -33,6 +34,8 @@ composer:
key: composer
paths:
- .composer-cache/
except:
- /^fastlane\/.+$/

test:
stage: test
Expand All @@ -44,6 +47,8 @@ test:
- php bin/adminconsole doctrine:schema:update --force
script:
- php composer.phar test
except:
- /^fastlane\/.+$/

lint:
stage: test
Expand All @@ -55,6 +60,8 @@ lint:
- php bin/adminconsole doctrine:schema:update --force
script:
- php composer.phar lint
except:
- /^fastlane\/.+$/

js-css:
stage: test
Expand All @@ -72,6 +79,17 @@ js-css:
key: npm
paths:
- .npm-cache/
except:
- /^fastlane\/.+$/

security-check:
stage: test
image: sulu/php:7.2-cli
script:
- php composer.phar security-check
allow_failure: true
except:
- /^fastlane\/.+$/

build:
stage: build
Expand Down Expand Up @@ -124,3 +142,50 @@ build:
only:
- master
- /^deploy\/.+$/
- /^fastlane\/.+$/

deploy-prod:
stage: deploy
image: sulu/helm-gcloud:2.13.1
dependencies: []
variables:
DEPLOY_NAME: 'sulu-demo'
before_script:
- helm init --client-only
- helm repo add sulu http://charts.sulu.cloud
- helm repo update
- cd deploy && helm dep build && cd ..
script:
- echo "$SECRET_PROD_VALUES" > deploy/secret.prod.yaml
- helm upgrade --install $DEPLOY_NAME deploy --wait --values deploy/secret.prod.yaml --set=sulu.app.image.tag=$CI_COMMIT_SHA --set=sulu.app.image.repository=$DOCKER_IMAGE/prod
environment:
name: prod
url: https://sulu.rocks
when: manual
only:
- master
- /^deploy\/.+$/
- /^fastlane\/.+$/

deploy-stage:
stage: deploy
image: sulu/helm-gcloud:2.13.1
dependencies: []
variables:
DEPLOY_NAME: 'sulu-demo-stage'
before_script:
- helm init --client-only
- helm repo add sulu http://charts.sulu.cloud
- helm repo update
- cd deploy && helm dep build && cd ..
script:
- echo "$SECRET_STAGE_VALUES" > deploy/secret.stage.yaml
- helm upgrade --install $DEPLOY_NAME deploy --wait --values deploy/secret.stage.yaml --set=sulu.app.image.tag=$CI_COMMIT_SHA --set=sulu.app.image.repository=$DOCKER_IMAGE/stage
environment:
name: staging
url: https://stage.sulu.rocks
when: manual
only:
- master
- /^deploy\/.+$/
- /^fastlane\/.+$/
79 changes: 79 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# install php dependencies in intermediate container
FROM composer:latest AS composer

WORKDIR /var/www/html

COPY composer.* /var/www/html/

RUN composer global require hirak/prestissimo --no-plugins --no-scripts
RUN composer install --apcu-autoloader -o --no-dev --no-scripts --ignore-platform-reqs

# install admin javascript dependencies and build assets in intermediate container
FROM node:12 AS node-admin

COPY composer.json /var/www/html/
COPY assets/admin /var/www/html/assets/admin
COPY --from=composer /var/www/html/vendor/sulu/sulu /var/www/html/vendor/sulu/sulu
COPY --from=composer /var/www/html/vendor/friendsofsymfony/jsrouting-bundle /var/www/html/vendor/friendsofsymfony/jsrouting-bundle

RUN cd /var/www/html/assets/admin && npm ci && NODE_OPTIONS="--max_old_space_size=4096" npm run build

# install website javascript dependencies and build assets in intermediate container
FROM node:12 AS node-website

COPY assets/website /var/www/html/assets/website
COPY public/website /var/www/html/public/website

RUN cd /var/www/html/assets/website && npm ci && npm run build:css && npm run build:js

# build actual application image
FROM php:7.2-apache AS apache

WORKDIR /var/www/html

# install packages
# inkscape is recommended for handling svg files with imagemagick
RUN apt-get update && apt-get install -y \
openssl \
git \
unzip \
libicu-dev \
libmagickwand-dev \
inkscape

# install PHP extensions
RUN docker-php-ext-configure intl && docker-php-ext-install -j$(nproc) \
intl \
pdo \
pdo_mysql \
opcache \
zip

RUN pecl install imagick redis apcu && docker-php-ext-enable imagick redis apcu

# apache config
RUN /usr/sbin/a2enmod rewrite && /usr/sbin/a2enmod headers && /usr/sbin/a2enmod expires

# copy needed files from build containers
COPY --from=node-admin /var/www/html/public/build/ /var/www/html/public/build/
COPY --from=node-website /var/www/html/public/website/ /var/www/html/public/website/
COPY --from=composer /var/www/html/vendor/ /var/www/html/vendor/

COPY . /var/www/html/

FROM apache AS prod

# php config
ADD ./deploy/config/php.prod.ini /usr/local/etc/php/conf.d/custom.ini

# apache config
COPY ./deploy/config/prod.conf /etc/apache2/sites-available/000-default.conf

FROM apache AS stage

# php config
ADD ./deploy/config/php.stage.ini /usr/local/etc/php/conf.d/custom.ini

# apache config
COPY ./deploy/config/.htpasswd /etc/apache2/.htpasswd
COPY ./deploy/config/stage.conf /etc/apache2/sites-available/000-default.conf
Loading

0 comments on commit 478b761

Please sign in to comment.