Skip to content

Commit e029d2f

Browse files
committed
setup deployment
1 parent a5787cf commit e029d2f

4 files changed

Lines changed: 135 additions & 6 deletions

File tree

.github/workflows/cd.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
run-name: Build push and deploy (CD)
2+
on:
3+
push:
4+
branches:
5+
- main
6+
tags:
7+
- '*'
8+
9+
jobs:
10+
build-and-push-to-gcr:
11+
runs-on: ubuntu-latest
12+
concurrency:
13+
group: ${{ github.ref_type == 'branch' && github.ref }}
14+
cancel-in-progress: true
15+
permissions:
16+
contents: read
17+
outputs:
18+
image-name: ${{ steps.set-image-name.outputs.image_name }}
19+
release-version: ${{ steps.set-image-name.outputs.release_version }}
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: 'google-github-actions/auth@v2'
23+
with:
24+
credentials_json: '${{ secrets.GCLOUD_SERVICE_ACCOUNT_SECRET_JSON }}'
25+
- name: 'Set up Cloud SDK'
26+
uses: 'google-github-actions/setup-gcloud@v2'
27+
with:
28+
install_components: beta
29+
- name: "Docker auth"
30+
run: |-
31+
gcloud auth configure-docker asia-southeast1-docker.pkg.dev --quiet
32+
- name: Set controller release version
33+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
34+
- name: Set up Node.js
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: 24.14.0
38+
cache: npm
39+
40+
- name: npm install
41+
run: npm ci
42+
- name: build application
43+
run: npm run build
44+
- name: npm install fe
45+
run: npm ci
46+
working-directory: fe
47+
- name: build fe
48+
run: npm run build
49+
working-directory: fe
50+
- name: Set package version
51+
run: npm version --no-git-tag-version ${{ env.RELEASE_VERSION }}
52+
if: github.ref_type == 'tag'
53+
- name: Docker meta
54+
id: meta
55+
uses: docker/metadata-action@v5
56+
with:
57+
images: |
58+
asia-southeast1-docker.pkg.dev/elastic-ml/jina-demo/wikipedia-vector-demo
59+
- name: Set up QEMU
60+
uses: docker/setup-qemu-action@v3
61+
- name: Set up Docker Buildx
62+
uses: docker/setup-buildx-action@v3
63+
- name: Build and push
64+
id: container
65+
uses: docker/build-push-action@v6
66+
with:
67+
context: .
68+
push: true
69+
tags: ${{ steps.meta.outputs.tags }}
70+
labels: ${{ steps.meta.outputs.labels }}
71+
- name: Set image name
72+
id: set-image-name
73+
run: |
74+
echo "image_name=asia-southeast1-docker.pkg.dev/elastic-ml/jina-demo/wikipedia-vector-demo@${{steps.container.outputs.imageid}}" >> $GITHUB_OUTPUT
75+
echo "release_version=${{ env.RELEASE_VERSION }}" >> $GITHUB_OUTPUT
76+
77+
deploy-services:
78+
runs-on: ubuntu-latest
79+
needs: build-and-push-to-gcr
80+
if: github.ref_name != 'ops'
81+
strategy:
82+
matrix:
83+
region: [asia-southeast1]
84+
steps:
85+
- uses: 'google-github-actions/auth@v2'
86+
with:
87+
credentials_json: '${{ secrets.GCLOUD_SERVICE_ACCOUNT_SECRET_JSON }}'
88+
- name: 'Set up Cloud SDK'
89+
uses: 'google-github-actions/setup-gcloud@v2'
90+
with:
91+
install_components: beta
92+
- name: Deploy Demo Server with Tag (${{ matrix.region }})
93+
run: |
94+
gcloud beta run deploy wikipedia-vector-demo --image ${{ needs.build-and-push-to-gcr.outputs.image-name }} --tag ${{ needs.build-and-push-to-gcr.outputs.release-version }} --command '' --args build/server.js --region ${{ matrix.region }} --async --min-instances 0 --deploy-health-check --use-http2

Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# syntax=docker/dockerfile:1
2+
FROM node:24
3+
4+
RUN groupadd -r jina
5+
RUN useradd -g jina -G audio,video -m jina
6+
USER jina
7+
8+
WORKDIR /app
9+
10+
COPY package.json package-lock.json ./
11+
RUN npm ci
12+
13+
COPY build ./build
14+
COPY public ./public
15+
COPY fe/dist ./fe/dist
16+
17+
18+
ENV PORT=8080
19+
20+
EXPOSE 3000 3001 8080 8081
21+
ENTRYPOINT ["node"]
22+
CMD [ "build/server.js" ]

package-lock.json

Lines changed: 16 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"license": "ISC",
66
"author": "",
77
"type": "commonjs",
8-
"main": "index.js",
8+
"main": "build/server.js",
99
"scripts": {
1010
"test": "echo \"Error: no test specified\" && exit 1",
1111
"build": "tsc -p ."
@@ -27,6 +27,7 @@
2727
"pino-pretty": "^13.1.3",
2828
"reflect-metadata": "^0.2.2",
2929
"tslib": "^2.8.1",
30-
"typescript": "^5.9.3"
30+
"typescript": "^5.9.3",
31+
"zod": "^4.3.6"
3132
}
3233
}

0 commit comments

Comments
 (0)