Skip to content

Commit

Permalink
Merge pull request #113 from sineverba/release-1.2.0
Browse files Browse the repository at this point in the history
Release 1.2.0
  • Loading branch information
sineverba authored Jan 15, 2024
2 parents c59e0c5 + 470632f commit ffefd1a
Show file tree
Hide file tree
Showing 24 changed files with 7,675 additions and 7,054 deletions.
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ jobs:

test:
docker:
- image: cimg/node:18.16.0
- image: cimg/node:20.11.0

steps:
- checkout
- run: npm install -g [email protected]
- run: npm ci
- run: CI=true npm run test

Expand Down
2 changes: 1 addition & 1 deletion .env.bak
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
REACT_APP_NAME="Bank"
REACT_APP_VERSION=$npm_package_version
REACT_APP_BACKEND_URL="https://bitbankapi.k2p.it/api/v1"
REACT_APP_BACKEND_URL="https://bitbankapi.k2p.it/api"
REACT_APP_LOCALSTORAGE_ACCESS_TOKEN="4fd9c72ddd8176dffe9f"
SONAR_LOGIN=YOUR_SONAR_TOKEN_HERE
SONAR_HOST_URL=http://localhost:9000
2 changes: 1 addition & 1 deletion .env.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
REACT_APP_NAME="Bank"
REACT_APP_VERSION="9.8.7"
REACT_APP_BACKEND_URL="https://api.example.com/v1"
REACT_APP_BACKEND_URL="https://api.example.com"
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18.16.0
v20.11.0
22 changes: 10 additions & 12 deletions .semaphore/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,17 @@ global_job_config:
- name: GITLAB_REGISTRY
value: registry.gitlab.com
- name: BUILDX_VERSION
value: 0.10.5
- name: BINFMT_VERSION
value: qemu-v7.0.0-28
value: 0.12.1
- name: NODE_VERSION
value: 20.11.0
- name: NPM_VERSION
value: 9.7.1
value: 10.3.0
- name: NGINX_VERSION
value: 1.25.3
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"
Expand All @@ -43,14 +41,14 @@ blocks:
-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 create --name multiarch --use
- docker buildx inspect --bootstrap --builder multiarch
- >-
docker buildx build
--platform linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64/v8
--build-arg NODE_VERSION=$NODE_VERSION
--build-arg NPM_VERSION=$NPM_VERSION
--build-arg NGINX_VERSION=$NGINX_VERSION
--tag $DOCKER_IMAGE:$SEMAPHORE_GIT_TAG_NAME
--tag $DOCKER_IMAGE:latest
--push
Expand Down
9 changes: 4 additions & 5 deletions .semaphore/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ global_job_config:
value: registry.gitlab.com/cicdprojects/online-banking-frontend
- name: GITLAB_REGISTRY
value: registry.gitlab.com
- name: BUILDX_VERSION
value: 0.10.5
- name: BINFMT_VERSION
value: qemu-v7.0.0-28
- name: FOLDER_APP
value: online-banking-frontend
- name: BUILDX_VERSION
value: 0.12.1
- name: NPM_VERSION
value: 9.7.1
value: 10.3.0

prologue:
commands:
- checkout
Expand Down
4 changes: 2 additions & 2 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ global_job_config:
- name: ACCESS_TOKENS
env_vars:
- name: NPM_VERSION
value: 9.7.1
value: 10.3.0
- name: SONARSCANNER_VERSION
value: 4.8.0
value: 5.0.1
prologue:
commands:
- checkout
Expand Down
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# 1.1.0
# 1.2.0
+ Upgrade dependencies
+ Move v1 to the code
+ Remove servers inside tests
+ Refactor login tests
+ Upgrade dependencies
+ Upgrade dependencies
+ Refactor Docker build

## 1.1.0
+ Upgrade dependencies
+ Refactor tests
+ Upgrade dependencies
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License

Copyright (c) 2022 - 2023 sineverba
Copyright (c) 2022 - 2024 sineverba

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
42 changes: 22 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ include .env

IMAGE_NAME=registry.gitlab.com/cicdprojects/online-banking-frontend
CONTAINER_NAME=online-banking-frontend
APP_VERSION=1.1.0-dev
SONARSCANNER_VERSION=4.8.0
BUILDX_VERSION=0.10.5
BINFMT_VERSION=qemu-v7.0.0-28
APP_VERSION=1.2.0-dev
NODE_VERSION=20.11.0
NPM_VERSION=10.3.0
NGINX_VERSION=1.25.3
SONARSCANNER_VERSION=5.0.1
BUILDX_VERSION=0.12.1


sonar:
docker run --rm -it \
Expand All @@ -16,8 +19,11 @@ sonar:
sonarsource/sonar-scanner-cli:$(SONARSCANNER_VERSION)

upgrade:
npx ncu -u
npx browserslist@latest --update-db
npx ncu -u \
-x @reduxjs/toolkit \
-x msw \
-x react-redux
npx update-browserslist-db@latest
npm install
npm audit fix

Expand All @@ -28,38 +34,34 @@ preparemulti:
mkdir -vp ~/.docker/cli-plugins
curl -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 rm multiarch
docker buildx create --name multiarch --driver docker-container --use
docker buildx inspect --bootstrap --builder multiarch
docker buildx create --name multiarch --use

deletecache:
docker builder prune

build:
npm run build
docker build \
--build-arg NODE_VERSION=$(NODE_VERSION) \
--build-arg NPM_VERSION=$(NPM_VERSION) \
--build-arg NGINX_VERSION=$(NGINX_VERSION) \
--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/production/build/docker/Dockerfile "."
rm -r build

test:
docker run --rm -it --name $(CONTAINER_NAME) $(IMAGE_NAME):$(APP_VERSION) cat /etc/os-release | grep "Alpine Linux v3.17"
docker run --rm -it --name $(CONTAINER_NAME) $(IMAGE_NAME):$(APP_VERSION) cat /etc/os-release | grep "VERSION_ID=3.17.2"
docker run --rm -it $(IMAGE_NAME):$(APP_VERSION) cat /etc/os-release | grep "Alpine Linux v3.18"
docker run --rm -it $(IMAGE_NAME):$(APP_VERSION) cat /etc/os-release | grep "VERSION_ID=3.18.5"
docker run --rm -it $(IMAGE_NAME):$(APP_VERSION) nginx -v | grep $(NGINX_VERSION)

spin:
docker container run -it --rm --publish 8080:80 --name $(CONTAINER_NAME) $(IMAGE_NAME):$(APP_VERSION)

destroy:
docker image rm nginx:1.23.3-alpine-slim
docker image rm $(IMAGE_NAME):$(APP_VERSION)
51 changes: 48 additions & 3 deletions dockerfiles/production/build/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,54 @@
######################################
#
# TESTER
#
######################################
ARG NODE_VERSION=latest
ARG NGINX_VERSION=latest
FROM --platform=$BUILDPLATFORM node:${NODE_VERSION}-alpine3.19 AS tester
ENV CI=true
ARG NPM_VERSION=latest
ENV NPM_VERSION $NPM_VERSION
# Add a workdir directory
WORKDIR /app
# Copy all files
COPY ./ .
# Update node
RUN npm install -g npm@$NPM_VERSION && npm -v | grep $NPM_VERSION && npm install
RUN npm run eslint
RUN npm pkg set scripts.test="CI=true react-scripts test"
RUN npm run test


######################################
#
# BUILDER
#
######################################
FROM --platform=$BUILDPLATFORM node:${NODE_VERSION}-alpine3.19 AS builder
# Add a workdir directory
WORKDIR /app
# Copy all files
COPY ./ .
# Skip prepare
RUN npm pkg set scripts.prepare="echo no-prepare"
# Update node, npm install dependencies with ignore-scripts to skip prepare
RUN npm install -g npm@$NPM_VERSION && npm install --omit=dev
RUN npm run build

######################################
#
# PRODUCTION
#
######################################
# Use NGINX
FROM nginx:1.23.3-alpine-slim
FROM --platform=$BUILDPLATFORM nginx:${NGINX_VERSION}-alpine3.18-slim AS production
# Update and upgrade
RUN apk update --no-cache && apk upgrade
RUN apk update && \
apk upgrade --available --no-cache && \
rm -rf /var/cache/apk/*
# Copy from builder
COPY build /usr/share/nginx/html
COPY --from=builder /app/build /usr/share/nginx/html
# Copy nginx configuration
COPY dockerfiles/production/build/nginx/app.conf /etc/nginx/conf.d/default.conf
# Expose port
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/production/deploy/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3.8"
services:
online-banking-frontend:
image: registry.gitlab.com/cicdprojects/online-banking-frontend:1.1.0
image: registry.gitlab.com/cicdprojects/online-banking-frontend:1.2.0
container_name: ${CONTAINER_NAME}
restart: unless-stopped
env_file:
Expand Down
Loading

0 comments on commit ffefd1a

Please sign in to comment.