Skip to content

Commit 45a4695

Browse files
committed
fix: various workflow updates, docker file changes and old files tidy up
1 parent e948c18 commit 45a4695

9 files changed

Lines changed: 192 additions & 120 deletions

File tree

.github/workflows/dev-build.yml

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ on:
1616
branches: [development]
1717

1818
env:
19-
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
20-
GKE_CLUSTER_DEV: nmrxiv-dev
21-
GKE_ZONE: europe-west3-a
2219
DEPLOYMENT_NAME: nmrxiv-nmrium
2320
DOCKER_HUB_USERNAME : ${{ secrets.DOCKER_HUB_USERNAME }}
2421
DOCKER_HUB_PASSWORD : ${{ secrets.DOCKER_HUB_PASSWORD }}
@@ -46,21 +43,6 @@ jobs:
4643
VERSION=${GITHUB_REF//*\/}
4744
echo "export default { version: '$VERSION' };" > src/versionInfo.ts
4845
49-
# Setup gcloud CLI
50-
- name: Setup CLI
51-
uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7
52-
with:
53-
service_account_key: ${{ secrets.GKE_SA_KEY }}
54-
project_id: ${{ secrets.GKE_PROJECT }}
55-
56-
# Get the GKE credentials so we can deploy to the cluster
57-
- name: Get GKE credentials
58-
uses: google-github-actions/get-gke-credentials@v0.3.0
59-
with:
60-
cluster_name: ${{ env.GKE_CLUSTER_DEV }}
61-
location: ${{ env.GKE_ZONE }}
62-
credentials: ${{ secrets.GKE_SA_KEY }}
63-
6446
- name: Log in to Docker Hub
6547
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
6648
with:
@@ -78,10 +60,3 @@ jobs:
7860
tags: ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:dev-latest
7961
username: ${{ env.DOCKER_HUB_USERNAME }}
8062
password: ${{ env.DOCKER_HUB_PASSWORD }}
81-
82-
# Deploy the latest Docker image to the GKE cluster
83-
- name: Deploy
84-
run: |-
85-
kubectl rollout restart deployment/$DEPLOYMENT_NAME
86-
kubectl rollout status deployment/$DEPLOYMENT_NAME --timeout=300s
87-
kubectl get services -o wide

.github/workflows/prod-build.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
2+
# This worklflow will perform following actions when a release is published:
3+
# - Fetch Latest release.
4+
# - Build the latest docker image in production.
5+
# - Build release and commit to repo.
6+
# - Push the docker image to Github Artifact Registry-Prod.
7+
# - Rollout latest docker image to GKE.
8+
#
9+
# Maintainers:
10+
# - name: Nisha Sharma
11+
# - email: nisha.sharma@uni-jena.de
12+
13+
name : Build and Deploy to Prod
14+
15+
on:
16+
push:
17+
branches: [prod-helm-deploy]
18+
19+
env:
20+
DEPLOYMENT_NAME: nmrxiv-nmrium
21+
DOCKER_HUB_USERNAME : ${{ secrets.DOCKER_HUB_USERNAME }}
22+
DOCKER_HUB_PASSWORD : ${{ secrets.DOCKER_HUB_PASSWORD }}
23+
REPOSITORY_NAME: nmrium-react-wrapper
24+
REPOSITORY_NAMESPACE: nfdi4chem
25+
26+
jobs:
27+
setup-build-publish-deploy-prod:
28+
name: Deploy to prod
29+
if: github.ref == 'refs/heads/prod-helm-deploy'
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4.1.7
34+
35+
# Login to Docker Hub
36+
- name: Log in to Docker Hub
37+
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
38+
with:
39+
username: ${{ env.DOCKER_HUB_USERNAME }}
40+
password: ${{ env.DOCKER_HUB_PASSWORD }}
41+
42+
#Fetch latest release
43+
- name: Fetch latest release
44+
id: fetch-latest-release
45+
uses: InsonusK/get-latest-release@v1.1.0
46+
with:
47+
myToken: ${{ github.token }}
48+
exclude_types: "draft|prerelease"
49+
view_top: 10
50+
- name: "Print release name"
51+
run: |
52+
echo "tag_name: ${{ steps.fetch-latest-release.outputs.tag_name }}"
53+
54+
#Build and push Docker image to Docker Hub
55+
- name: Build and push Docker image
56+
uses: docker/build-push-action@v4
57+
with:
58+
context: .
59+
file: ./Dockerfile.prod
60+
push: true
61+
build-args: |
62+
RELEASE_VERSION=${{ steps.fetch-latest-release.outputs.tag_name }}
63+
tags: ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:${{ steps.fetch-latest-release.outputs.tag_name }}, ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:latest
64+
username: ${{ env.DOCKER_HUB_USERNAME }}
65+
password: ${{ env.DOCKER_HUB_PASSWORD }}
66+
67+
# Build npm for release
68+
- name: Build npm
69+
run: |-
70+
npm install
71+
npm run build -- --outDir=build
72+
npm run build -- --outDir=releases/${{ steps.fetch-latest-release.outputs.tag_name }}
73+
74+
# Commit
75+
- name: Commit to repo
76+
uses: EndBug/add-and-commit@v9.1.4
77+
with:
78+
default_author: github_actions

Dockerfile

Lines changed: 0 additions & 11 deletions
This file was deleted.

Dockerfile.dev

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# build environment
2-
FROM node:22-alpine as build
2+
FROM node:22-alpine3.18 as build
3+
34
WORKDIR /app
45
ENV PATH /app/node_modules/.bin:$PATH
56
COPY package.json ./

Dockerfile.prod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
FROM node:22-alpine3.18 as build
33

44
# ARG RELEASE_VERSION
5-
# ENV RELEASE_VERSION=${RELEASE_VERSION}
5+
ENV RELEASE_VERSION=${RELEASE_VERSION}
66

77
WORKDIR /app
88
ENV PATH /app/node_modules/.bin:$PATH
@@ -13,7 +13,7 @@ RUN npm i react-scripts@latest -g --silent
1313
COPY . ./
1414
RUN echo "export default { version: '$RELEASE_VERSION' };" > src/versionInfo.ts
1515
RUN npm run build -- --outDir=build
16-
RUN npm run build -- --outDir=build/releases/v0.0.1
16+
RUN npm run build -- --outDir=build/releases/${RELEASE_VERSION}
1717

1818
# production environment
1919
FROM nginx:stable-alpine

README.old.md

Lines changed: 0 additions & 70 deletions
This file was deleted.

docker-compose.local.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
version: '3.7'
2+
3+
services:
4+
# Development environment
5+
nmrium-dev:
6+
container_name: nmrium-dev
7+
build:
8+
context: .
9+
dockerfile: Dockerfile.dev
10+
restart: always
11+
networks:
12+
- nmrium-network
13+
environment:
14+
- NODE_ENV=development
15+
- CHOKIDAR_USEPOLLING=true
16+
17+
# Production environment
18+
nmrium-prod:
19+
container_name: nmrium-prod
20+
build:
21+
context: .
22+
dockerfile: Dockerfile.prod
23+
restart: always
24+
networks:
25+
- nmrium-network
26+
environment:
27+
- NODE_ENV=production
28+
- RELEASE_VERSION=latest
29+
30+
# Nginx reverse proxy
31+
nginx-proxy:
32+
container_name: nginx-proxy
33+
image: nginx:stable-alpine
34+
ports:
35+
- "8080:80" # Dev environment on port 8080
36+
- "8081:81" # Prod environment on port 8081
37+
volumes:
38+
- ./nginx/proxy.conf:/etc/nginx/conf.d/default.conf
39+
depends_on:
40+
- nmrium-dev
41+
- nmrium-prod
42+
networks:
43+
- nmrium-network
44+
45+
networks:
46+
nmrium-network:
47+
driver: bridge

docker-compose.yml

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,43 @@
11
version: '3.7'
22

33
services:
4+
# Development environment
5+
nmrium-dev:
6+
container_name: nmrium-dev
7+
image: nfdi4chem/nmrium-react-wrapper:dev-latest
8+
restart: always
9+
networks:
10+
- nmrium-network
11+
environment:
12+
- NODE_ENV=development
13+
- CHOKIDAR_USEPOLLING=true
414

5-
sample:
6-
container_name: nmrium-rw
7-
build:
8-
context: .
9-
dockerfile: Dockerfile
10-
volumes:
11-
- '.:/app'
12-
- '/app/node_modules'
13-
ports:
14-
- 3001:3000
15+
# Production environment
16+
nmrium-prod:
17+
container_name: nmrium-prod
18+
image: nfdi4chem/nmrium-react-wrapper:latest
19+
restart: always
20+
networks:
21+
- nmrium-network
1522
environment:
16-
- CHOKIDAR_USEPOLLING=true
23+
- NODE_ENV=production
24+
- RELEASE_VERSION=latest
25+
26+
# Nginx reverse proxy
27+
nginx-proxy:
28+
container_name: nginx-proxy
29+
image: nginx:stable-alpine
30+
ports:
31+
- "8080:80" # Dev environment on port 8080
32+
- "8081:81" # Prod environment on port 8081
33+
volumes:
34+
- ./nginx/proxy.conf:/etc/nginx/conf.d/default.conf
35+
depends_on:
36+
- nmrium-dev
37+
- nmrium-prod
38+
networks:
39+
- nmrium-network
40+
41+
networks:
42+
nmrium-network:
43+
driver: bridge

nginx/proxy.conf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
server {
2+
listen 80;
3+
4+
location / {
5+
proxy_pass http://nmrium-dev:80;
6+
proxy_http_version 1.1;
7+
proxy_set_header Upgrade $http_upgrade;
8+
proxy_set_header Connection 'upgrade';
9+
proxy_set_header Host $host;
10+
proxy_cache_bypass $http_upgrade;
11+
}
12+
}
13+
14+
server {
15+
listen 81;
16+
17+
location / {
18+
proxy_pass http://nmrium-prod:80;
19+
proxy_http_version 1.1;
20+
proxy_set_header Upgrade $http_upgrade;
21+
proxy_set_header Connection 'upgrade';
22+
proxy_set_header Host $host;
23+
proxy_cache_bypass $http_upgrade;
24+
}
25+
}

0 commit comments

Comments
 (0)