Skip to content

Commit b82a2df

Browse files
authored
Merge pull request #210 from makeopensource/fix-deployment
Fix CI/CD
2 parents c023e92 + daf4335 commit b82a2df

14 files changed

Lines changed: 306 additions & 209 deletions

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/**/node_modules
22
/logs
3-
/devU-api/src/tango/tests/test_files
3+
/devU-api/src/tango/tests/test_files
4+
.env.*

.github/workflows/api.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Builds DevU api
2+
name: Build DevU api
3+
4+
on:
5+
push:
6+
paths:
7+
- 'devU-api/**'
8+
branches:
9+
- develop # add more branches as needed
10+
11+
jobs:
12+
build-api-docker:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write # to be able to publish a GitHub release
16+
packages: write # to be able to publish docker image packages
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
submodules: recursive
21+
fetch-depth: 0
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
26+
- name: Login to GHCR registry
27+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
28+
29+
- name: Convert image name to lowercase
30+
run: |
31+
original_string=${{ github.repository }}
32+
echo "repo_url=$(echo $original_string | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
33+
34+
- name: Get Branch Name
35+
id: get_branch
36+
run: echo "::set-output name=branch_name::${GITHUB_REF#refs/heads/}"
37+
38+
- name: build api docker
39+
run: |
40+
IMAGE_NAME=ghcr.io/${{ env.repo_url }}/api:${{ steps.get_branch.outputs.branch_name }}
41+
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
42+
43+
docker build . -f api.Dockerfile -t $IMAGE_NAME
44+
docker push $IMAGE_NAME
45+
46+
- name: build tango docker
47+
run: |
48+
IMAGE_NAME=ghcr.io/${{ env.repo_url }}/tango:${{ steps.get_branch.outputs.branch_name }}
49+
docker build ./tango -f ./tango/Dockerfile -t $IMAGE_NAME
50+
docker push $IMAGE_NAME

.github/workflows/client.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Builds DevU client
2+
name: Build DevU client
3+
4+
on:
5+
push:
6+
paths:
7+
- 'devU-client/**'
8+
branches:
9+
- develop # add more branches as needed
10+
11+
jobs:
12+
build-client-docker:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write # to be able to publish a GitHub release
16+
packages: write # to be able to publish packages
17+
steps:
18+
- uses: actions/checkout@v3
19+
with:
20+
submodules: recursive
21+
fetch-depth: 0
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
26+
- name: Login to GHCR registry
27+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
28+
29+
- name: Convert image name to lowercase
30+
run: |
31+
original_string=${{ github.repository }}
32+
echo "repo_url=$(echo $original_string | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
33+
34+
- name: Get Branch Name
35+
id: get_branch
36+
run: echo "::set-output name=branch_name::${GITHUB_REF#refs/heads/}"
37+
38+
- name: build client docker
39+
run: |
40+
IMAGE_NAME=ghcr.io/${{ env.repo_url }}/client:${{ steps.get_branch.outputs.branch_name }}
41+
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
42+
43+
docker build . -f client.Dockerfile -t $IMAGE_NAME
44+
docker push $IMAGE_NAME
45+
46+
- name: build nginx
47+
run: |
48+
IMAGE_NAME=ghcr.io/${{ env.repo_url }}/nginx:${{ steps.get_branch.outputs.branch_name }}
49+
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
50+
51+
docker build . -f nginx.Dockerfile -t $IMAGE_NAME
52+
docker push $IMAGE_NAME

.github/workflows/dev.yml

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

.github/workflows/release.yml

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

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ node_modules/
66
/.vscode
77
/logs
88
/*/node_modules
9-
/*/package-lock.json
9+
/*/package-lock.json
10+
levi

api.Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:20 AS module_builder
1+
FROM node:22-alpine AS module_builder
22

33
WORKDIR /tmp
44

@@ -21,7 +21,7 @@ COPY devU-api/config/ ./config
2121

2222
RUN ./generateConfig.sh default.yml
2323

24-
FROM node:20
24+
FROM node:22-alpine
2525

2626
WORKDIR /app
2727

@@ -43,4 +43,3 @@ RUN chmod +x /wait
4343

4444
# TypeORM Migrations
4545
CMD /wait && npm run typeorm -- migration:run -d src/database.ts && npm start
46-

client.Dockerfile

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:16 AS module_builder
1+
FROM node:22-alpine AS module_builder
22

33
WORKDIR /tmp
44

@@ -8,7 +8,7 @@ RUN npm install && \
88
npm run clean-directory && \
99
npm run build-docker
1010

11-
FROM node:16 AS frontend
11+
FROM node:22-alpine
1212

1313
WORKDIR /app
1414

@@ -20,12 +20,5 @@ COPY ./devU-client/ .
2020

2121
COPY --from=module_builder /tmp/devu-shared-modules ./devu-shared-modules
2222

23-
RUN npm run build-local
24-
25-
# final stage serve frontend files
26-
FROM nginx:1.23.3
27-
28-
COPY nginx.conf /etc/nginx/nginx.conf
29-
30-
# Copy built frontend files to nginx serving directory
31-
COPY --from=frontend /app/dist/local /usr/share/nginx/html
23+
# build frontend during run so that we can modify baseurl via docker envoirment
24+
CMD npm run --silent build-docker && rm -rf /out/* && cp -r /app/dist/* /out

devU-client/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"build-development": "cross-env NODE_ENV=development webpack --mode=production",
99
"build-all": "concurrently \"npm run build-development\" \"npm run build\"",
1010
"build-local": "cross-env NODE_ENV=local webpack --mode=production",
11+
"build-docker": "SASS_DEPRECATE_IMPORT=no webpack --mode=production --no-stats",
1112
"format": "prettier --write \"src/**/*.{ts,tsx,json,md}\"",
1213
"pre-commit": "lint-staged",
1314
"dev-backend": "docker compose -f ../docker-compose.yml --profile dev-client up -d",
@@ -78,7 +79,7 @@
7879
"sass-loader": "^10.2.0",
7980
"style-loader": "^2.0.0",
8081
"ts-loader": "^8.0.15",
81-
"webpack": "^5.91.0",
82+
"webpack": "^5.98.0",
8283
"webpack-bundle-analyzer": "^4.10.2",
8384
"webpack-cli": "^5.1.4",
8485
"webpack-dev-server": "^5.0.4"

docker-compose.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,27 @@ services:
1515
- '' # so it starts with normal docker compose
1616
- 'dev-client' # start when developing client
1717

18-
client-nginx:
19-
# Builds the front end and serves the frontend static files using nginx
18+
client:
19+
# Builds the front end and exports static files to ./dist
2020
build:
21+
context: .
2122
dockerfile: client.Dockerfile
23+
volumes:
24+
- ./dist:/out
25+
profiles:
26+
- '' # so it starts with normal docker compose
27+
- 'dev-api' # start when developing api
28+
29+
nginx:
30+
# Hosts the front end static files from ./dist/local thorough a web server
31+
build:
2232
context: .
33+
dockerfile: nginx.Dockerfile
34+
volumes:
35+
- ./dist/local:/usr/share/nginx/html
36+
depends_on:
37+
client:
38+
condition: service_completed_successfully
2339
ports:
2440
- '9000:80'
2541
profiles:
@@ -54,6 +70,16 @@ services:
5470
MINIO_ROOT_PASSWORD: changeMe
5571
command: server /data --console-address ":9001"
5672

73+
# leviathan:
74+
# container_name: leviathan
75+
# image: ghcr.io/makeopensource/leviathan:dev
76+
# ports:
77+
# - "9221:9221"
78+
# volumes:
79+
# - /var/run/docker.sock:/var/run/docker.sock
80+
# - ./levi/:/app/appdata
81+
# restart: unless-stopped
82+
5783
# tango stuff
5884
tango:
5985
container_name: tango

0 commit comments

Comments
 (0)