Skip to content

Commit

Permalink
Merge pull request #89 from sineverba/release-0.11.0
Browse files Browse the repository at this point in the history
Release 0.11.0
  • Loading branch information
sineverba authored Jan 27, 2023
2 parents 319cab3 + 25becbe commit 8caf336
Show file tree
Hide file tree
Showing 11 changed files with 187 additions and 111 deletions.
72 changes: 0 additions & 72 deletions .semaphore/build-deploy.yml

This file was deleted.

63 changes: 63 additions & 0 deletions .semaphore/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
version: v1.0

name: Build
agent:
machine:
type: e1-standard-2
os_image: ubuntu2004

global_job_config:
secrets:
- name: ACCESS_TOKENS
env_vars:
- name: DOCKER_IMAGE
value: registry.gitlab.com/cicdprojects/online-banking-frontend
- name: GITLAB_REGISTRY
value: registry.gitlab.com
- name: BUILDX_VERSION
value: 0.10.0
- name: BINFMT_VERSION
value: qemu-v7.0.0-28
- name: NPM_VERSION
value: 9.4.0
prologue:
commands:
- checkout
- cp .env.bak .env
- npm install -g npm@$NPM_VERSION
- npm pkg set scripts.prepare="echo no-prepare"
- npm install --omit=dev
- npm run build

blocks:
- name: "Build"
task:
jobs:
- name: Create Docker image
commands:
- docker login -u semaphore -p $GITLAB_TOKEN $GITLAB_REGISTRY
- mkdir -vp ~/.docker/cli-plugins/
- >-
curl
--silent
-L "https://github.com/docker/buildx/releases/download/v$BUILDX_VERSION/buildx-v$BUILDX_VERSION.linux-amd64"
> ~/.docker/cli-plugins/docker-buildx
- chmod a+x ~/.docker/cli-plugins/docker-buildx
- docker buildx version
- docker run --rm --privileged tonistiigi/binfmt:$BINFMT_VERSION --install all
- docker buildx ls
- docker buildx create --name multiarch --driver docker-container --use
- docker buildx inspect --bootstrap --builder multiarch
- >-
docker buildx build
--platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8
--tag $DOCKER_IMAGE:$SEMAPHORE_GIT_TAG_NAME
--tag $DOCKER_IMAGE:latest
--push
--file ./dockerfiles/production/build/docker/Dockerfile "."
promotions:
- name: Deploy
pipeline_file: deploy.yml
auto_promote:
when: "result = 'passed' and tag =~ '.*'"
74 changes: 74 additions & 0 deletions .semaphore/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
version: v1.0

name: Deploy
agent:
machine:
type: e1-standard-2
os_image: ubuntu2004

global_job_config:
secrets:
- name: ACCESS_TOKENS
- name: VPS
env_vars:
- name: DOCKER_IMAGE
value: registry.gitlab.com/cicdprojects/online-banking-frontend
- name: GITLAB_REGISTRY
value: registry.gitlab.com
- name: BUILDX_VERSION
value: 0.10.0
- name: BINFMT_VERSION
value: qemu-v7.0.0-28
- name: FOLDER_APP
value: online-banking-frontend
- name: NPM_VERSION
value: 9.4.0
prologue:
commands:
- checkout
- cp .env.bak .env

blocks:
- name: "Deploy"
task:
jobs:
- name: Deploy to Netlify
commands:
- npm install -g npm@$NPM_VERSION
- npm pkg set scripts.prepare="echo no-prepare"
- npm install --omit=dev
- npm install netlify-cli -g
- npm run build
- netlify deploy -s $NETLIFY_BITBANK_SITE_ID --auth $NETLIFY_ACCESS_TOKEN -p --dir ./build
- name: Deploy to Vercel
commands:
- npm install -g npm@$NPM_VERSION
- npm pkg set scripts.prepare="echo no-prepare"
- npm install --omit=dev
- npm install -g vercel
- VERCEL_PROJECT_ID=$VERCEL_BITBANK_PROJECT_ID VERCEL_ORG_ID=$VERCEL_ORG_ID npx vercel --token $VERCEL_TOKEN --confirm --prod
- name: Deploy to VPS
commands:
- ssh-keyscan -p $VPS01_OCI_PORT -H $VPS01_OCI_URL >> ~/.ssh/known_hosts
- chmod 0600 ~/.ssh/id_semaphore
- ssh-add ~/.ssh/id_semaphore
# 1 - Stop the container and remove it
- >-
ssh -t $VPS01_OCI_USERNAME@$VPS01_OCI_URL -p $VPS01_OCI_PORT
"cd $FOLDER_APP && docker-compose stop && docker container rm $FOLDER_APP && exit"
# 2 - Remove all tagged images
- >-
ssh -t $VPS01_OCI_USERNAME@$VPS01_OCI_URL -p $VPS01_OCI_PORT
"docker images | grep $FOLDER_APP | tr -s ' ' | cut -d ' ' -f 2 | xargs -I {} docker rmi $DOCKER_IMAGE:{} && exit"
# 3 - Pull the image
- >-
ssh -t $VPS01_OCI_USERNAME@$VPS01_OCI_URL -p $VPS01_OCI_PORT
"docker pull $DOCKER_IMAGE:$SEMAPHORE_GIT_TAG_NAME && exit"
# 4 - Replace the docker-compose with new tag image
- >-
ssh -t $VPS01_OCI_USERNAME@$VPS01_OCI_URL -p $VPS01_OCI_PORT
"sed -i \"/image\: registry.gitlab.com\/cicdprojects\/$FOLDER_APP:/c\ image\: registry.gitlab.com\/cicdprojects\/$FOLDER_APP\:$SEMAPHORE_GIT_TAG_NAME\" $FOLDER_APP/docker-compose.yml && exit"
# 6 - Restart the service
- >-
ssh -t $VPS01_OCI_USERNAME@$VPS01_OCI_URL -p $VPS01_OCI_PORT
"cd $FOLDER_APP && docker-compose up -d && exit"
9 changes: 6 additions & 3 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ agent:
global_job_config:
secrets:
- name: ACCESS_TOKENS
env_vars:
- name: NPM_VERSION
value: 9.4.0
prologue:
commands:
- checkout
- npm install -g npm@9.3.1
- npm install -g npm@$NPM_VERSION

blocks:

Expand Down Expand Up @@ -54,7 +57,7 @@ blocks:
- docker run --rm -e SONAR_HOST_URL="https://sonarcloud.io" -e SONAR_LOGIN=$SONAR_TOKEN -v "/home/semaphore/online-banking-frontend:/usr/src" sonarsource/sonar-scanner-cli:4.8.0

promotions:
- name: Deploy
pipeline_file: build-deploy.yml
- name: Build
pipeline_file: build.yml
auto_promote:
when: "result = 'passed' and tag =~ '.*'"
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# 0.10.1
# 0.11.0
+ Upgrade dependencies + Refactor Semaphore

## 0.10.1
+ Fix Semaphore

## 0.10.0
Expand Down
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include .env

IMAGE_NAME=registry.gitlab.com/cicdprojects/online-banking-frontend
CONTAINER_NAME=online-banking-frontend
APP_VERSION=0.10.1-dev
APP_VERSION=0.11.0-dev
SONARSCANNER_VERSION=4.8.0
BUILDX_VERSION=0.10.0
BINFMT_VERSION=qemu-v7.0.0-28
Expand Down Expand Up @@ -37,12 +37,17 @@ preparemulti:

build:
npm run build
docker build --tag $(IMAGE_NAME):$(APP_VERSION) --file dockerfiles/Dockerfile .
docker build --tag $(IMAGE_NAME):$(APP_VERSION) --file dockerfiles/production/build/docker/Dockerfile "."
rm -r build

multi:
npm run build
docker buildx build --platform linux/arm64/v8,linux/amd64,linux/arm/v6,linux/arm/v7 --tag $(IMAGE_NAME):$(APP_VERSION) --tag $(IMAGE_NAME):latest --push --file dockerfiles/Dockerfile .
docker buildx build \
--platform linux/arm64/v8,linux/amd64,linux/arm/v6,linux/arm/v7 \
--tag $(IMAGE_NAME):$(APP_VERSION) \
--tag $(IMAGE_NAME):latest \
--push \
--file dockerfiles/production/build/docker/Dockerfile "."
rm -r build

test:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RUN apk update --no-cache && apk upgrade
# Copy from builder
COPY build /usr/share/nginx/html
# Copy nginx configuration
COPY dockerfiles/nginx/app.conf /etc/nginx/conf.d/default.conf
COPY dockerfiles/production/build/nginx/app.conf /etc/nginx/conf.d/default.conf
# Expose port
EXPOSE 80
# Start nginx
Expand Down
File renamed without changes.
Loading

0 comments on commit 8caf336

Please sign in to comment.