@horat1us/release-utils
v4.5.0
Published
## Docker Nginx Build Script
Readme
Release Utils
Docker Nginx Build Script
The docker/nginx/build.sh script builds and pushes a Docker image for serving static files using nginx.
Installation
This script is available as a bin command when the package is installed:
npm install -g @horat1us/release-utilsUsage
# When installed globally via npm
docker-build-nginx [directory] [fallback_file]
# When running directly
./docker/nginx/build.sh [directory] [fallback_file]Arguments
- directory (optional) - Directory containing files to copy to the image (default: current directory)
- fallback_file (optional) - Fallback file for client-side routing in nginx config (default:
index.html)
Examples
# Build from current directory with default index.html fallback
docker-build-nginx
# Build from dist directory with default index.html fallback
docker-build-nginx ./dist
# Build from dist directory with custom fallback file
docker-build-nginx ./dist app.htmlEnvironment Variables
IMAGE_REPOSITORY- Docker image repository name (default: from package.json name or current directory name)IMAGE_TAG- Docker image tag (default: from package.json version or CODEBUILD_BUILD_NUMBER)CODEBUILD_BUILD_ID- When set, uses AWS ECR registry and authenticationAWS_DEFAULT_REGION- AWS region for ECR (default: eu-central-1)
Features
- Uses
docker.io/bobra/nginx:1.29.1as base image - Copies specified directory contents to
/static/in the container - Configures nginx to use
static.confwith customizable fallback file for SPAs - Automatically detects AWS CodeBuild environment and uses ECR
- Generates
imagedefinitions.jsonfor AWS CodeDeploy
Telegram-notify
Поддерживает отправку сообщений 2 вариантами:
- Когда в текущей папке есть файл env.json и в нем лежат все переменные, полученные путем выполнения файла https://gist.githubusercontent.com/Horat1us/8ffc5814b0f3c5fbf95370ac8b778455/raw/1b234ab19ca514caa8e098736493b3795781203e/codebuild-git-env.sh на стадии билда проекта на AWS Codebuild. А также существуют переменные REPO_OWNER (владелец репозитория) и GITHUB_AUTH_TOKEN (токен авторизации к github).
- При наличии переменных окружения таких как: GIT_COMMIT_MESSAGE, GIT_COMMIT_AUTHOR, GIT_COMMIT_URL, GITHUB_REPOSITORY (например: "facebook/react"), FAILURE (0 | 1).
Также в обоих случаях нужны переменные окружения BOT_API_KEY (ключ телеграм бота), CHAT_ID.
Examples
AWS CodeBuild
curl -O https://gist.githubusercontent.com/Horat1us/8ffc5814b0f3c5fbf95370ac8b778455/raw/1b234ab19ca514caa8e098736493b3795781203e/codebuild-git-env.sh
chmod +x ./codebuild-git-env.sh
./codebuild-git-env.sh > ./env.json
if [[ "$CODEBUILD_BUILD_SUCCEEDING" == "0" ]]; then
npm i -g @horat1us/[email protected];
telegram-notify-deploy;
fi;GitHub Actions
name: Set commit variables
if: ${{ always() }}
run: |
echo "GIT_COMMIT_MESSAGE=$(git log --format=%B -n 1 ${{ github.event.after }})" >> $GITHUB_ENV
echo "GIT_COMMIT_AUTHOR=$(git log --format=%an -n 1 ${{ github.event.after }})" >> $GITHUB_ENV
echo "GIT_COMMIT_URL=https://github.com/${GITHUB_REPOSITORY}/commit/${{ github.event.after }}" >> $GITHUB_ENV
name: Send deploy notification
if: ${{ always() }}
env:
FAILURE: ${{ env.FAILURE }}
GIT_COMMIT_MESSAGE: ${{ env.GIT_COMMIT_MESSAGE }}
GIT_COMMIT_AUTHOR: ${{ env.GIT_COMMIT_AUTHOR }}
GIT_COMMIT_URL: ${{ env.GIT_COMMIT_URL }}
run: |
npm i -g @horat1us/[email protected]
telegram-notify-deploy