Skip to content

Commit 07655ab

Browse files
authored
Merge pull request #6 from Between-Freedom-and-Space/develop
Added Webpack and CI Deploy
2 parents a89c44f + 583158f commit 07655ab

20 files changed

+2566
-772
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Build Dockerfile
2+
3+
on:
4+
pull_request:
5+
branches: [ "main", "develop" ]
6+
7+
jobs:
8+
build:
9+
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- name: Build the Docker image
14+
run: docker build . --file Dockerfile --tag web-backend-facade:$(date +%s)

.github/workflows/testing-deploy.yml

Lines changed: 53 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
name: Deploy web backend facade to testing stage
1+
name: Deploy Web-Backend-Facade to testing stage
22

33
on:
44
workflow_dispatch:
55
inputs:
66
name:
7-
description: 'Deploy author'
7+
description: 'Deploy Implementer'
88
default: 'World'
99
required: true
1010
release-version:
@@ -20,38 +20,55 @@ jobs:
2020
runs-on: ubuntu-latest
2121

2222
steps:
23-
- name: Send greeting
24-
run: echo "Hello ${{ github.event.inputs.name }}"
25-
- name: Show deploy ticket
26-
run: echo "Deploy ticket ${{ github.event.inputs.name }}"
23+
- name: Send greeting
24+
run: echo "Hello ${{ github.event.inputs.name }}"
25+
- name: Show deploy ticket
26+
run: echo "Deploy ticket ${{ github.event.inputs.name }}"
27+
2728
deploy:
28-
runs-on: ubuntu-latest
29-
environment: testing
30-
31-
steps:
32-
- uses: actions/checkout@v3
33-
34-
- name: Login to Yandex Cloud Container Registry
35-
id: login-cr
36-
uses: yc-actions/yc-cr-login@v1
37-
with:
38-
yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
39-
40-
- name: Build docker image
41-
env:
42-
CR_REGISTRY: crpp4a802h6om9om40b4
43-
CR_REPOSITORY: web-backend-facade
44-
IMAGE_TAG: ${{ github.event.inputs.release-version }}
45-
run: docker build . --file Dockerfile --tag cr.yandex/$CR_REGISTRY/$CR_REPOSITORY:$IMAGE_TAG
46-
47-
- name: Push docker image to Yandex.Cloud registry
48-
env:
49-
CR_REGISTRY: crpp4a802h6om9om40b4
50-
CR_REPOSITORY: web-backend-facade
51-
IMAGE_TAG: ${{ github.event.inputs.release-version }}
52-
run: docker push cr.yandex/$CR_REGISTRY/$CR_REPOSITORY:$IMAGE_TAG
53-
54-
- name: Wait untill Yandex.Clout process new docker image
55-
uses: jakejarvis/wait-action@v0.1.1
56-
with:
57-
time: '180s'
29+
runs-on: ubuntu-latest
30+
environment: testing
31+
32+
steps:
33+
- uses: actions/checkout@v3
34+
35+
- name: Login to Yandex Cloud Container Registry
36+
id: login-cr
37+
uses: yc-actions/yc-cr-login@v1
38+
with:
39+
yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
40+
41+
- name: Build docker image
42+
env:
43+
CR_REGISTRY: crpp4a802h6om9om40b4
44+
CR_REPOSITORY: web-backend-facade
45+
IMAGE_TAG: ${{ github.event.inputs.release-version }}
46+
run: docker build . --file Dockerfile --tag cr.yandex/$CR_REGISTRY/$CR_REPOSITORY:$IMAGE_TAG
47+
48+
- name: Push docker image to Yandex.Cloud registry
49+
env:
50+
CR_REGISTRY: crpp4a802h6om9om40b4
51+
CR_REPOSITORY: web-backend-facade
52+
IMAGE_TAG: ${{ github.event.inputs.release-version }}
53+
run: docker push cr.yandex/$CR_REGISTRY/$CR_REPOSITORY:$IMAGE_TAG
54+
55+
- name: Wait untill Yandex.Cloud process new docker image
56+
uses: jakejarvis/wait-action@v0.1.1
57+
with:
58+
time: '30s'
59+
60+
- name: Substitute the real value of variables
61+
env:
62+
ENV_MONO_BACKEND_URL: ${{ secrets.MONOLITH_URL }}
63+
run: |
64+
sed -i 's|$REGISTRY_ID|crpp4a802h6om9om40b4|g' ./k8s/deployment.testing.yaml
65+
sed -i 's|$REPOSITORY_NAME|mono-backend|g' ./k8s/deployment.testing.yaml
66+
sed -i 's|$IMAGE_TAG|${{ github.event.inputs.release-version }}|g' ./k8s/deployment.testing.yaml
67+
sed -i "s|{{MONO_BACKEND_URL}}|$ENV_MONO_BACKEND_URL|g" ./k8s/deployment.testing.yaml
68+
69+
- name: Deploy to k8s
70+
uses: actions-hub/kubectl@master
71+
env:
72+
KUBE_CONFIG: ${{ secrets.TESTING_K8S_CONFIG }}
73+
with:
74+
args: config view

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,6 @@ dist
102102

103103
# TernJS port file
104104
.tern-port
105+
106+
# Webpack build file
107+
build

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM node:14
2+
3+
RUN mkdir -p app
4+
WORKDIR app
5+
COPY . .
6+
RUN npm install
7+
RUN npm run build
8+
RUN npm run env
9+
RUN npm ci --only=production
10+
11+
EXPOSE 8585:8585
12+
13+
CMD [ "npm", "run", "prod" ]

configs/webpack.config.cjs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const buildConfig = {
2+
"src": "src/app/server.js",
3+
"build": "build",
4+
"target": "server.js"
5+
}
6+
7+
const path = require('path')
8+
const nodeExternals = require('webpack-node-externals')
9+
10+
const ROOT_PATH = path.resolve(__dirname, '..')
11+
const PATH = path.resolve(ROOT_PATH, buildConfig.src)
12+
13+
module.exports = (env, args) => {
14+
return {
15+
entry: {
16+
build: PATH
17+
},
18+
mode: "production",
19+
output: {
20+
filename: buildConfig.target,
21+
publicPath: "/",
22+
path: path.resolve(ROOT_PATH, buildConfig.build)
23+
},
24+
resolve: {
25+
extensions: [
26+
".js", ".json"
27+
],
28+
modules: [
29+
path.resolve(ROOT_PATH, 'node_modules')
30+
]
31+
},
32+
target: 'node',
33+
externals: [nodeExternals()],
34+
node: {
35+
__dirname: false,
36+
__filename: false,
37+
},
38+
module: {
39+
rules: [
40+
{
41+
test: /\.js$/,
42+
include: PATH,
43+
exclude: /node_modules/,
44+
use: {
45+
loader: "babel-loader"
46+
},
47+
}
48+
]
49+
50+
}
51+
}
52+
}

k8s.yaml

Whitespace-only changes.

k8s/deployment.production.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: web-backend-facade-deployment
5+
labels:
6+
app: web-backend-facade
7+
owner: Ferum-bot
8+
tier: backend
9+
stage: production
10+
infrastructure: js
11+
namespace: default
12+
spec:
13+
replicas: 2
14+
selector:
15+
matchLabels:
16+
app: web-backend-facade-application
17+
stage: production
18+
template:
19+
metadata:
20+
labels:
21+
app: web-backend-facade-application
22+
stage: production
23+
spec:
24+
containers:
25+
- name: web-backend-facade-container
26+
image: cr.yandex/$REGISTRY_ID/$REPOSITORY_NAME:$IMAGE_TAG
27+
ports:
28+
- containerPort: 8585
29+
hostPort: 8585
30+
env:
31+
- name: MONO_BACKEND_URL
32+
value: {{MONO_BACKEND_URL}}

k8s/deployment.testing.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: web-backend-facade-deployment
5+
labels:
6+
app: web-backend-facade
7+
owner: Ferum-bot
8+
tier: backend
9+
stage: testing
10+
infrastructure: js
11+
namespace: default
12+
spec:
13+
replicas: 2
14+
selector:
15+
matchLabels:
16+
app: web-backend-facade-application
17+
stage: testing
18+
template:
19+
metadata:
20+
labels:
21+
app: web-backend-facade-application
22+
stage: testing
23+
spec:
24+
containers:
25+
- name: web-backend-facade-container
26+
image: cr.yandex/$REGISTRY_ID/$REPOSITORY_NAME:$IMAGE_TAG
27+
ports:
28+
- containerPort: 8585
29+
hostPort: 8585
30+
env:
31+
- name: MONO_BACKEND_URL
32+
value: {{MONO_BACKEND_URL}}

0 commit comments

Comments
 (0)