-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1221 from iturgeon/iturgeon/polish-docker-scripts…
…-and-environ-for-deploys polish docker scripts and clean up release builds
- Loading branch information
Showing
18 changed files
with
302 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# important: this tag must be updated | ||
# when theres a change to any dockerfile | ||
# | ||
# to update: use the next upcoming git tag | ||
# dockerub builds an image for every tag | ||
TAG=v5.0.0 | ||
|
||
FUEL_ENV=development | ||
|
||
# Database settings | ||
DB_HOST=mysql | ||
MYSQL_ROOT_PASSWORD=drRoots | ||
MYSQL_USER=materia | ||
MYSQL_PASSWORD=odin | ||
MYSQL_DATABASE=materia | ||
|
||
# Fake S3 | ||
INPUT_BUCKET=fakes3_uploads | ||
OUTPUT_BUCKET=fakes3_assets | ||
OUTPUT_MAX_DIMENSIONS=75x75, 0x0 | ||
OUTPUT_BASE_KEY=media | ||
IS_FAKES3=True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
#!/bin/bash | ||
####################################################### | ||
# ABOUT THIS SCRIPT | ||
# | ||
# Install and build a base release package | ||
# This should try to include as many constructed | ||
# assets as possible to reduce the work needed | ||
# to deploy Materia. This build will not | ||
# disrupt the current files on disk - | ||
# ex: no need to install node # or npm packages | ||
# to build js - just include the js | ||
# | ||
# EX: ./run_build_release_package.sh | ||
####################################################### | ||
set -e | ||
|
||
# declare files that should have been created | ||
declare -a FILES_THAT_SHOULD_EXIST=( | ||
"public/js/materia.enginecore.js" | ||
"public/css/widget-play.css" | ||
) | ||
|
||
# declare files to omit from zip | ||
declare -a FILES_TO_EXCLUDE=( | ||
".git*" | ||
".gitignore" | ||
"app.json" | ||
"nginx_app.conf" | ||
"Procfile" | ||
"node_modules*" | ||
"githooks" | ||
"phpcs.xml" | ||
"src*" | ||
"fuel/app/config/development*" | ||
"fuel/app/config/heroku*" | ||
"fuel/app/config/test*" | ||
"fuel/app/config/production*" | ||
"public/widget*" | ||
"githooks*" | ||
"coverage.xml" | ||
"coverage*" | ||
) | ||
|
||
# combine the files to exclude | ||
EXCLUDE='' | ||
for i in "${FILES_TO_EXCLUDE[@]}" | ||
do | ||
EXCLUDE="$EXCLUDE --exclude=\"./$i\"" | ||
done | ||
|
||
# store the docker compose command to shorten the following commands | ||
DC="docker-compose -f docker-compose.yml -f docker-compose.admin.yml" | ||
|
||
set -o xtrace | ||
|
||
# # stop and remove docker containers | ||
$DC down --volumes --remove-orphans | ||
|
||
$DC pull --ignore-pull-failures node | ||
|
||
# get rid of any left over package files | ||
rm -rf clean_build_clone || true | ||
rm -rf ../materia-pkg* || true | ||
git clone ../ ./clean_build_clone | ||
|
||
# gather build info | ||
DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") | ||
GITUSER=$(git config user.name) | ||
GITEMAIL=$(git config user.email) | ||
GITCOMMIT=$(cd clean_build_clone && git rev-parse HEAD) | ||
GITREMOTE=$(cd clean_build_clone&& git remote get-url origin) | ||
|
||
# remove .git dir for slightly faster copy | ||
rm -rf clean_build_clone/.git | ||
|
||
# start a build container | ||
$DC run --no-deps --detach --workdir /build/clean_build_clone --name materia-build node tail -f /dev/null | ||
|
||
# copy the clean build clone into the container | ||
docker cp ./clean_build_clone materia-build:/build | ||
|
||
# clean up | ||
rm -rf clean_build_clone || true | ||
|
||
# install production node_modules | ||
docker exec materia-build yarn install --frozen-lockfile --non-interactive --production | ||
|
||
# verify all files we expect to be created exist | ||
for i in "${FILES_THAT_SHOULD_EXIST[@]}" | ||
do | ||
docker exec materia-build stat /build/clean_build_clone/$i | ||
done | ||
|
||
# zip, excluding some files | ||
docker exec materia-build bash -c "zip -r $EXCLUDE ../materia-pkg.zip ./" | ||
|
||
# calulate hashes | ||
MD5=$(docker exec materia-build md5sum ../materia-pkg.zip) | ||
SHA1=$(docker exec materia-build sha1sum ../materia-pkg.zip) | ||
SHA256=$(docker exec materia-build sha256sum ../materia-pkg.zip) | ||
|
||
# copy zip file from container to host | ||
docker cp materia-build:/build/materia-pkg.zip ../materia-pkg.zip | ||
|
||
# write build info file | ||
echo "build_date: $DATE" > ../materia-pkg-build-info.yml | ||
echo "git: $GITREMOTE" >> ../materia-pkg-build-info.yml | ||
echo "git_version: $GITCOMMIT" >> ../materia-pkg-build-info.yml | ||
echo "git_user: $GITUSER" >> ../materia-pkg-build-info.yml | ||
echo "git_user_email: $GITEMAIL" >> ../materia-pkg-build-info.yml | ||
echo "sha1: $SHA1" >> ../materia-pkg-build-info.yml | ||
echo "sha256: $SHA256" >> ../materia-pkg-build-info.yml | ||
echo "md5: $MD5" >> ../materia-pkg-build-info.yml | ||
|
||
# clean environment and configs | ||
$DC down --volumes --remove-orphans |
Oops, something went wrong.