-
Notifications
You must be signed in to change notification settings - Fork 76
Update: migration to distroless #42
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
Open
itninja-hue
wants to merge
5
commits into
0xb4lamx:master
Choose a base branch
from
itninja-hue:update
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,15 @@ | ||
| MYSQL_HOST=mysql | ||
| MYSQL_USERNAME=root | ||
| MYSQL_PASSWORD=example | ||
| MYSQL_DATABASE=boilerplate_db | ||
| MYSQL_PORT=3306 | ||
| EVENT_STORE_HOSTNAME=eventstore | ||
| EVENT_STORE_CREDENTIALS_USERNAME=admin | ||
| EVENT_STORE_CREDENTIALS_PASSWORD=changeit | ||
| EVENT_STORE_PROTOCOL=http | ||
| EVENT_STORE_TCP_PORT=1113 | ||
| EVENT_STORE_HTTP_PORT=2113 | ||
| EVENT_STORE_POOLOPTIONS_MIN=1 | ||
| EVENT_STORE_POOLOPTIONS_MAX=10 | ||
| PORT=3000 | ||
| HOST=0.0.0.0 |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -390,8 +390,8 @@ Temporary Items | |
|
|
||
| ======= | ||
| # Local | ||
| docker-compose.yml | ||
| *.env | ||
| dist | ||
| logs | ||
| data/ | ||
| .config/ | ||
| .npm/ | ||
This file contains hidden or 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 hidden or 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,149 @@ | ||
| #!/bin/sh | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good stuff, we need to update README accoding to this? for better experience using the new CLI 🤔 (didn't test it intensively yet) |
||
|
|
||
| #script goals | ||
|
|
||
| # ---- HELP ---- | ||
| help(){ | ||
| echo "boiler-ctl command line tool to manage projetcs" | ||
| echo | ||
| echo "Syntax: boiler-ctl [init|stop|logs|install|commit|clean] [ARGS]" | ||
| echo "options" | ||
| echo "init Initiate project, creates data folders and containerized environment." | ||
| echo "stop Stop project containerized environment." | ||
| echo "logs Print and tail container logs, no args for all containers logs, or specify docker-compose service name(s)." | ||
| echo "install Install node package(s) seperated by a blank space." | ||
| echo "commit Print interactive commit menu implemnts conventional commits." | ||
| echo "clean Stops containers if up and deletes data and node_modules folder." | ||
| } | ||
|
|
||
| # ---- VARS ---- | ||
| DEFAULT_NODE_CONTAINER_TAG="node:lts-alpine3.9" | ||
| DEFAULT_NODE_CONTAINER_PACKAGE_MANAGER="npm" | ||
|
|
||
| # ---- CHECK REQ ---- | ||
| for cmd in git docker docker-compose; | ||
| do | ||
| command -v "${cmd}" >/dev/null || { | ||
| echo "[$(date +%D-%H:%M)][REQ]: Error! ${cmd} is required, but not found." | ||
| exit 1 | ||
| }; | ||
| done | ||
| [ -d ".git" ] || { | ||
| echo "[$(date)][REQ]: Error! boiler-ctl only wokrs on git repositories." | ||
| exit 1 | ||
| } | ||
|
|
||
| # ---- CHECK NUMBER OF ARGS ---- | ||
| [ "$#" != "0" ] || { | ||
| echo "[$(date +%D-%H:%M)][REQ]: Error! no args has been suplied, maybe use --help for list of options." | ||
| exit 1 | ||
| } | ||
|
|
||
| # ---- HANDLE ARGS ---- | ||
| case $1 in | ||
| init) | ||
| shift | ||
| [ "$#" != "0" ] && { | ||
| echo "[$(date +%D-%H:%M)][INIT][CONFIG]: too much arguments." | ||
| exit 1 | ||
| } | ||
| [ -f ./docker-compose.yml ] && echo "[$(date +%D-%H:%M)][INIT][CONFIG]: docker-compose.yml file found" || { | ||
| echo "[$(date +%D-%H:%M)][INIT][CONFIG]: Error! docker-compose.yml file is required, but not found." | ||
| exit 1 | ||
| } | ||
| docker-compose up | ||
| ;; | ||
| stop) | ||
| shift | ||
| [ "$#" != "0" ] && { | ||
| echo "[$(date +%D-%H:%M)][STOP][CONFIG]: too much arguments." | ||
| exit 1 | ||
| } | ||
| [ -f ./docker-compose.yml ] && echo "[$(date +%D-%H:%M)][INIT][CONFIG]: docker-compose.yml file found" || { | ||
| echo "[$(date +%D-%H:%M)][STOP][CONFIG]: Error! docker-compose.yml file is required, but not found." | ||
| exit 1 | ||
| } | ||
| docker-compose down | ||
| ;; | ||
| logs) | ||
| shift | ||
| docker-compose logs -t -f "$@" | ||
| ;; | ||
| install) | ||
| shift | ||
| [ "$#" != "0" ] || { | ||
| echo "[$(date +%D-%H:%M)][INSTALL][CONFIG]: Error! no package name detected, please provide packages name seperated by space." | ||
| exit 1 | ||
| } | ||
| [ -f ./package.json ] && echo "[$(date +%D-%H:%M)][INSTALL][CONFIG]: package.json file found" || { | ||
| echo "[$(date +%D-%H:%M)][INSTALL][CONFIG]: Error! package.json file is required, but not found." | ||
| exit 1 | ||
| } | ||
| [ -n "$NODE_CONTAINER_TAG" ] && { | ||
| echo "[$(date +%D-%H:%M)][INSTALL][NODE_VERSION]: NODE_CONTAINER_TAG found. Using it instead of default" | ||
| $DEFAULT_NODE_CONTAINER_TAG="$NODE_CONTAINER_TAG" | ||
| } || { | ||
| echo "[$(date +%D-%H:%M)][INSTALL][NODE_VERSION]: Using default NODE_CONTAINER_TAG $DEFAULT_NODE_CONTAINER_TAG" | ||
| } | ||
| [ -n "$NODE_CONTAINER_PACKAGE_MANAGER" ] && { | ||
| echo "[$(date +%D-%H:%M)][INSTALL][NODE_PACKAGE_MANAGER]: NODE_CONTAINER_PACKAGE_MANAGER found. Using it instead of default" | ||
| $DEFAULT_NODE_CONTAINER_PACKAGE_MANAGER="$NODE_CONTAINER_PACKAGE_MANAGER" | ||
| } || { | ||
| echo "[$(date +%D-%H:%M)][INSTALL][NODE_VERSION]: Using default NODE_CONTAINER_PACKAGE_MANAGER $DEFAULT_NODE_CONTAINER_PACKAGE_MANAGER" | ||
| } | ||
| docker run --rm --name packge-install-job -w="/app" --mount type=bind,source="$(pwd)"/.,target="/app" \ | ||
| "$DEFAULT_NODE_CONTAINER_TAG" "$DEFAULT_NODE_CONTAINER_PACKAGE_MANAGER" install "$@" | ||
| ;; | ||
| commit) | ||
| shift | ||
| [ "$#" != "0" ] && { | ||
| echo "[$(date +%D-%H:%M)][COMMIT][CONFIG]: too much arguments." | ||
| exit 1 | ||
| } | ||
| docker run --rm --name commit-citizen-job -w="/app" --mount type=bind,source="$(pwd)"/.,target="/app" \ | ||
| -e HOME='.' -v ~/.gitconfig:/etc/gitconfig -a stdin -a stdout -a stderr -it timbru31/node-alpine-git npx git-cz --disable-emoji | ||
| ;; | ||
| clean) | ||
| shift | ||
| [ "$#" != "0" ] && { | ||
| echo "[$(date +%D-%H:%M)][CLEAN][CONFIG]: too much arguments." | ||
| exit 1 | ||
| } | ||
| [ -f ./docker-compose.yml ] && echo "[$(date +%D-%H:%M)][CLEAN][CONFIG]: docker-compose.yml file found" || { | ||
| echo "[$(date +%D-%H:%M)][CLEAN][CONFIG]: Error! docker-compose.yml file is required, but not found." | ||
| exit 1 | ||
| } | ||
| echo "[$(date +%D-%H:%M)][CLEAN][ENV]: stoping containers if up." | ||
| docker-compose down | ||
| [ -d "./data" ] && { | ||
| echo "[$(date +%D-%H:%M)][CLEAN][DATA]: data directory found, deleteing it." | ||
| docker run --rm --name clean-data-dir-job -w="/app" --mount type=bind,source="$(pwd)"/.,target="/app" alpine:3 rm -rfv ./data | ||
| } | ||
| [ -d "./node_modules" ] && { | ||
| echo "[$(date +%D-%H:%M)][CLEAN][DATA]: node_modules directory found, deleteing it." | ||
| docker run --rm --name clean-node_modules-job -w="/app" --mount type=bind,source="$(pwd)"/.,target="/app" alpine:3 rm -rfv node_modules | ||
| } | ||
| [ -d "./.npm" ] && { | ||
| echo "[$(date +%D-%H:%M)][CLEAN][DATA]: .npm directory found, deleteing it." | ||
| docker run --rm --name clean-npm_folder-job -w="/app" --mount type=bind,source="$(pwd)"/.,target="/app" alpine:3 rm -rfv ./.npm | ||
| } | ||
| [ -d "./.config" ] && { | ||
| echo "[$(date +%D-%H:%M)][CLEAN][DATA]: .config directory found, deleteing it." | ||
| docker run --rm --name clean-npm_folder-job -w="/app" --mount type=bind,source="$(pwd)"/.,target="/app" alpine:3 rm -rfv ./.config | ||
| } | ||
| [ -d "./dist" ] && { | ||
| echo "[$(date +%D-%H:%M)][CLEAN][DATA]: .config directory found, deleteing it." | ||
| docker run --rm --name clean-npm_folder-job -w="/app" --mount type=bind,source="$(pwd)"/.,target="/app" alpine:3 rm -rfv ./dist | ||
| } | ||
| ;; | ||
| help) | ||
| shift | ||
| [ "$#" != "0" ] && { | ||
| echo "[$(date +%D-%H:%M)][CLEAN][HELP]: too much arguments, help takes no args." | ||
| exit 1 | ||
| } | ||
| help | ||
| ;; | ||
| *) | ||
| echo "[$(date +%D-%H:%M)]: Error! unrecongnized arg, maybe use help for instructions." | ||
| esac | ||
This file contains hidden or 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,60 @@ | ||
| version: "3.1" | ||
| services: | ||
| app: | ||
| environment: | ||
| MYSQL_HOST: "${MYSQL_HOST}" | ||
| MYSQL_USERNAME: "${MYSQL_USERNAME}" | ||
| MYSQL_PASSWORD: ${MYSQL_PASSWORD} | ||
| MYSQL_DATABASE: "${MYSQL_DATABASE}" | ||
| MYSQL_PORT: "${MYSQL_PORT}" | ||
| EVENT_STORE_HOSTNAME: "${EVENT_STORE_HOSTNAME}" | ||
| EVENT_STORE_CREDENTIALS_USERNAME: "${EVENT_STORE_CREDENTIALS_USERNAME}" | ||
| EVENT_STORE_CREDENTIALS_PASSWORD: "${EVENT_STORE_CREDENTIALS_PASSWORD}" | ||
| EVENT_STORE_PROTOCOL: "${EVENT_STORE_PROTOCOL}" | ||
| EVENT_STORE_TCP_PORT: "${EVENT_STORE_TCP_PORT}" | ||
| EVENT_STORE_HTTP_PORT: "${EVENT_STORE_HTTP_PORT}" | ||
| EVENT_STORE_POOLOPTIONS_MIN: "${EVENT_STORE_POOLOPTIONS_MIN}" | ||
| EVENT_STORE_POOLOPTIONS_MAX: "${EVENT_STORE_POOLOPTIONS_MAX}" | ||
| PORT: "${PORT}" | ||
| HOST: "${HOST}" | ||
| container_name: awesome_nestjs_boilerplate | ||
| image: node:lts-alpine3.9 | ||
| working_dir: /app | ||
| command: | ||
| - sh | ||
| - -c | ||
| - apk add --no-cache git && /bin/su node -c 'npm -d install && npm run start:dev' | ||
| ports: | ||
| - "${PORT}:${PORT}" | ||
| volumes: | ||
| - type: "bind" | ||
| source: "./" | ||
| target: /app/ | ||
| mysql: | ||
| environment: | ||
| MYSQL_ROOT_PASSWORD: ${MYSQL_PASSWORD} | ||
| MYSQL_DATABASE: "${MYSQL_DATABASE}" | ||
| image: mysql:5.7 | ||
| command: | ||
| - --default-authentication-plugin=mysql_native_password | ||
| - --character-set-server=utf8mb4 | ||
| - --collation-server=utf8mb4_unicode_ci | ||
| container_name: "${MYSQL_HOST}" | ||
| volumes: | ||
| - ./data/mysql-data-dir:/var/lib/mysql | ||
| eventstore: | ||
| environment: | ||
| - EVENT_STORE_TCP_PORT="${EVENT_STORE_TCP_PORT}" | ||
| - EVENT_STORE_HTTP_PORT="${EVENT_STORE_HTTP_PORT}" | ||
| image: eventstore/eventstore:release-5.0.9 | ||
| container_name: "${EVENT_STORE_HOSTNAME}" | ||
| ports: | ||
| - "${EVENT_STORE_HTTP_PORT}:${EVENT_STORE_HTTP_PORT}" | ||
| - "${EVENT_STORE_TCP_PORT}:${EVENT_STORE_TCP_PORT}" | ||
| volumes: | ||
| - ./data/eventstore-data-dir:/var/lib/eventstore | ||
| adminer: | ||
| image: adminer | ||
| container_name: 'adminer' | ||
| ports: | ||
| - 8080:8080 |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.envfiles should not be pushed to git.we prepared an
.env.exampleto clone from locally 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that env file is loaded by docker-compose in build phase, it evals the docker compose and change the ${VARS} by its equivalent.