Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker deployment setup #19

Merged
merged 37 commits into from Oct 28, 2020
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
af617a0
first commit
Akpjunior94 Oct 10, 2020
2144e8e
first commit
RabsonJ Oct 10, 2020
8ca94b1
Initial commit
Simret Oct 10, 2020
e7d69a5
first commit (#7)
Akpjunior94 Oct 11, 2020
2abf41f
New frontend workflow (#8)
conquext Oct 11, 2020
6a2b119
create startup server
conquext Oct 11, 2020
ffabff6
integrate firebase
Oct 11, 2020
d8637de
Merge pull request #10 from TOBECHI-GH/rasheed2
conquext Oct 11, 2020
3c73ba9
move stuffs into folder to prevent workspace conflicts
conquext Oct 12, 2020
1a3a473
Merge pull request #11 from TOBECHI-GH/rasheed2
conquext Oct 12, 2020
cf199c8
logo upload file added
Akpjunior94 Oct 12, 2020
7f78838
Merge branch 'Frontend' into abraham
Akpjunior94 Oct 12, 2020
f429b4f
Refit abraham page into new structure (#9)
conquext Oct 12, 2020
40a488d
Merge branch 'Akpjunior94-abraham' into Frontend
Akpjunior94 Oct 12, 2020
419f213
include firebase config env
Oct 17, 2020
805d775
implement /invoice endpoints
Oct 17, 2020
736914f
fix bug
Oct 17, 2020
42939af
test firebase integrations
Oct 17, 2020
fc3675d
setup docker
Oct 18, 2020
388002b
include frontend build
Oct 19, 2020
fdedcbf
ready to deploy to dockerhub
conquext Oct 19, 2020
261d260
Merge pull request #21 from Akpjunior94/new-invoice
conquext Oct 19, 2020
c7f92b0
merge invoice page
conquext Oct 19, 2020
42d7dfc
fix bugs
conquext Oct 19, 2020
40cd72e
fix file issues
Oct 19, 2020
3559096
new build
Oct 19, 2020
75a3ff9
Merge pull request #22 from TOBECHI-GH/temp
conquext Oct 19, 2020
79403ea
force merge
Oct 19, 2020
69d24a6
Merge branch 'temp' into Frontend
Oct 19, 2020
dd9d0b3
create unix deploy script
Oct 19, 2020
e093b8a
Merge branch 'Frontend' of https://github.com/TOBECHI-GH/Web-ecom-8 i…
Oct 19, 2020
28c4169
merge frontend branch
Oct 20, 2020
e0aa2c0
resolve merge conflict
Oct 20, 2020
ae865a6
resolve merge conflict
Oct 20, 2020
577b306
new build
Oct 20, 2020
879c078
update description
Oct 20, 2020
3ba0a68
resolve conflict
Oct 28, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .babelrc
@@ -0,0 +1,5 @@
{
"presets": [
"es2015"
]
}
1 change: 1 addition & 0 deletions .dockerignore
@@ -0,0 +1 @@
node_modules
2 changes: 2 additions & 0 deletions .env
@@ -0,0 +1,2 @@
GIT_DEPLOR_DIR=dist
GIT_DEPLOY_REPO=https://github.com/TOBECHI-GH/Web-ecom-8
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
node_modules
server/node_modules
server/.DS_STORE
server/.env
7 changes: 7 additions & 0 deletions .huskyrc
@@ -0,0 +1,7 @@
{
"hooks": {
"pre-commit": "gulp lint",
"pre-push": "npm run lint",
"post-merge": "npm run deploy-2",
}
}
1 change: 1 addition & 0 deletions .publish
Submodule .publish added at 7a03ae
14 changes: 14 additions & 0 deletions Dockerfile
@@ -0,0 +1,14 @@
FROM node:12

WORKDIR /app

COPY server/package*.json ./

RUN npm install

COPY server/ .
COPY dist/ ./public/

ENV PORT=8080
conquext marked this conversation as resolved.
Show resolved Hide resolved

CMD ["npm", "start"]
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
72 changes: 71 additions & 1 deletion README.md
@@ -1 +1,71 @@
# GADS community project
# GADS community project

## Installation

Please download zip file from [Web-ecom-8](https://github.com/TOBECHI-GH/Web-ecom-8) repository.

or by Git:

```
git clone https://github.com/TOBECHI-GH/Web-ecom-8.git
```

Then Run the following commands from the root of the file directory

- cd Web-ecom-8
- git checkout Frontend
- npm i
- npm run start

(If there are any errors make sure to use nodejs version 11 and below)

## Deployment

Code will automatically be deployed to gh-pages on every merge.
To deploy the code manually, run the following commands

- npm run build
- npm run deploy

## Features

- Advanced CSS Reset [scss-reset](https://github.com/andreymatin/scss-reset)
- Tailwind CSS Utilities [Tailwind](https://tailwindcss.com/docs/)
- Basic SCSS Mixins Collection [scss-mixins](https://github.com/andreymatin/scss-mixins)
- Old browsers support ( > 1% popularity )
- Predefined export/import JavaScript modules
- Semantic reference

#### JavaScript

- Babel
- Rollup

#### Tests

- Automated HTML5 W3C Validation

## Contributing

For issues, bugs or imporvements please open an [issue](https://github.com/TOBECHI-GH/Web-ecom-8/issues/new)

### JavaScript development

- rollup
- rollup-plugin-babel

### Notification

- gulp-plumber
- gulp-notify

### Styles Automation

- gulp-sass
- gulp-postcss
- autoprefixer

## HTML Files

- index.html - main landing page
- client.html - client page
3 changes: 3 additions & 0 deletions babel.config.js
@@ -0,0 +1,3 @@
module.exports = {
presets: ["@babel/env"],
};
220 changes: 220 additions & 0 deletions deploy.Unix.sh
@@ -0,0 +1,220 @@
#!/usr/bin/env bash
set -o errexit #abort if any command fails
me=$(basename "$0")

help_message="\
Usage: $me [-c FILE] [<options>]
Deploy generated files to a git branch.

Options:

-h, --help Show this help information.
-v, --verbose Increase verbosity. Useful for debugging.
-e, --allow-empty Allow deployment of an empty directory.
-m, --message MESSAGE Specify the message used when committing on the
deploy branch.
-n, --no-hash Don't append the source commit's hash to the deploy
commit's message.
-c, --config-file PATH Override default & environment variables' values
with those in set in the file at 'PATH'. Must be the
first option specified.

Variables:

GIT_DEPLOY_DIR Folder path containing the files to deploy.
GIT_DEPLOY_BRANCH Commit deployable files to this branch.
GIT_DEPLOY_REPO Push the deploy branch to this repository.

These variables have default values defined in the script. The defaults can be
overridden by environment variables. Any environment variables are overridden
by values set in a '.env' file (if it exists), and in turn by those set in a
file specified by the '--config-file' option."

parse_args() {
# Set args from a local environment file.
if [ -e ".env" ]; then
source .env
fi

# Set args from file specified on the command-line.
if [[ $1 = "-c" || $1 = "--config-file" ]]; then
source "$2"
shift 2
fi

# Parse arg flags
# If something is exposed as an environment variable, set/overwrite it
# here. Otherwise, set/overwrite the internal variable instead.
while : ; do
if [[ $1 = "-h" || $1 = "--help" ]]; then
echo "$help_message"
return 0
elif [[ $1 = "-v" || $1 = "--verbose" ]]; then
verbose=true
shift
elif [[ $1 = "-e" || $1 = "--allow-empty" ]]; then
allow_empty=true
shift
elif [[ ( $1 = "-m" || $1 = "--message" ) && -n $2 ]]; then
commit_message=$2
shift 2
elif [[ $1 = "-n" || $1 = "--no-hash" ]]; then
GIT_DEPLOY_APPEND_HASH=false
shift
else
break
fi
done

# Set internal option vars from the environment and arg flags. All internal
# vars should be declared here, with sane defaults if applicable.

# Source directory & target branch.
deploy_directory=${GIT_DEPLOY_DIR:-dist}
deploy_branch=${GIT_DEPLOY_BRANCH:-gh-pages}

#if no user identity is already set in the current git environment, use this:
default_username=${GIT_DEPLOY_USERNAME:-deploy.sh}
default_email=${GIT_DEPLOY_EMAIL:-}

#repository to deploy to. must be readable and writable.
repo=${GIT_DEPLOY_REPO:-origin}

#append commit hash to the end of message by default
append_hash=${GIT_DEPLOY_APPEND_HASH:-true}
}

main() {
parse_args "$@"

enable_expanded_output

if ! git diff --exit-code --quiet --cached; then
echo Aborting due to uncommitted changes in the index >&2
return 1
fi

commit_title=`git log -n 1 --format="%s" HEAD`
commit_hash=` git log -n 1 --format="%H" HEAD`

#default commit message uses last title if a custom one is not supplied
if [[ -z $commit_message ]]; then
commit_message="publish: $commit_title"
fi

#append hash to commit message unless no hash flag was found
if [ $append_hash = true ]; then
commit_message="$commit_message"$'\n\n'"generated from commit $commit_hash"
fi

previous_branch=`git rev-parse --abbrev-ref HEAD`

if [ ! -d "$deploy_directory" ]; then
echo "Deploy directory '$deploy_directory' does not exist. Aborting." >&2
return 1
fi

# must use short form of flag in ls for compatibility with OS X and BSD
if [[ -z `ls -A "$deploy_directory" 2> /dev/null` && -z $allow_empty ]]; then
echo "Deploy directory '$deploy_directory' is empty. Aborting. If you're sure you want to deploy an empty tree, use the --allow-empty / -e flag." >&2
return 1
fi

if git ls-remote --exit-code $repo "refs/heads/$deploy_branch" ; then
# deploy_branch exists in $repo; make sure we have the latest version

disable_expanded_output
git fetch --force $repo $deploy_branch:$deploy_branch
enable_expanded_output
fi

# check if deploy_branch exists locally
if git show-ref --verify --quiet "refs/heads/$deploy_branch"
then incremental_deploy
else initial_deploy
fi

restore_head
}

initial_deploy() {
git --work-tree "$deploy_directory" checkout --orphan $deploy_branch
git --work-tree "$deploy_directory" add --all
commit+push
}

incremental_deploy() {
#make deploy_branch the current branch
git symbolic-ref HEAD refs/heads/$deploy_branch
#put the previously committed contents of deploy_branch into the index
git --work-tree "$deploy_directory" reset --mixed --quiet
git --work-tree "$deploy_directory" add --all

set +o errexit
diff=$(git --work-tree "$deploy_directory" diff --exit-code --quiet HEAD --)$?
set -o errexit
case $diff in
0) echo No changes to files in $deploy_directory. Skipping commit.;;
1) commit+push;;
*)
echo git diff exited with code $diff. Aborting. Staying on branch $deploy_branch so you can debug. To switch back to master, use: git symbolic-ref HEAD refs/heads/master && git reset --mixed >&2
return $diff
;;
esac
}

commit+push() {
set_user_id
git --work-tree "$deploy_directory" commit -m "$commit_message"

disable_expanded_output
#--quiet is important here to avoid outputting the repo URL, which may contain a secret token
git push --quiet $repo $deploy_branch
enable_expanded_output
}

#echo expanded commands as they are executed (for debugging)
enable_expanded_output() {
if [ $verbose ]; then
set -o xtrace
set +o verbose
fi
}

#this is used to avoid outputting the repo URL, which may contain a secret token
disable_expanded_output() {
if [ $verbose ]; then
set +o xtrace
set -o verbose
fi
}

set_user_id() {
if [[ -z `git config user.name` ]]; then
git config user.name "$default_username"
fi
if [[ -z `git config user.email` ]]; then
git config user.email "$default_email"
fi
}

restore_head() {
if [[ $previous_branch = "HEAD" ]]; then
#we weren't on any branch before, so just set HEAD back to the commit it was on
git update-ref --no-deref HEAD $commit_hash $deploy_branch
else
git symbolic-ref HEAD refs/heads/$previous_branch
fi

git reset --mixed
}

filter() {
sed -e "s|$repo|\$repo|g"
}

sanitize() {
"$@" 2> >(filter 1>&2) | filter
}

[[ $1 = --source-only ]] || main "$@"