Skip to content
This repository was archived by the owner on Mar 26, 2023. It is now read-only.

Commit 2f870be

Browse files
ilya101masterdyakovri
authored andcommitted
Style fixes and CI (#21)
1 parent 83e342e commit 2f870be

File tree

11 files changed

+150
-8908
lines changed

11 files changed

+150
-8908
lines changed

.dockerignore

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

.env.development

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
VUE_APP_CDN =https://cdn.test.profcomff.com
2+
3+
VUE_APP_MAIN =https://app.test.profcomff.com
4+
5+
VUE_APP_API_AGGREGATOR =https://aggregator.api.test.profcomff.com
6+
7+
VUE_APP_API_PRINTER =https://printer.api.test.profcomff.com
8+
9+
VUE_APP_API_REPORT =https://report.api.test.profcomff.com
10+
11+
VUE_APP_API_TIMETABLE =https://timetable.api.test.profcomff.com
12+
13+
VUE_APP_API_NAVBAR =https://navbar.api.test.profcomff.com
14+
15+
VUE_APP_API_MARKETING =https://marketing.api.test.profcomff.com

.env.production

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
VUE_APP_CDN =https://cdn.profcomff.com
2+
3+
VUE_APP_MAIN =https://app.profcomff.com
4+
5+
VUE_APP_API_AGGREGATOR =https://aggregator.api.profcomff.com
6+
7+
VUE_APP_API_PRINTER =https://printer.api.profcomff.com
8+
9+
VUE_APP_API_REPORT =https://report.api.profcomff.com
10+
11+
VUE_APP_API_TIMETABLE =https://timetable.api.profcomff.com
12+
13+
VUE_APP_API_NAVBAR =https://navbar.api.profcomff.com
14+
15+
VUE_APP_API_MARKETING =https://marketing.api.profcomff.com

.github/workflows/build_and_publish.yml

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ name: Build and publish a Docker image
33
on:
44
push:
55
branches: ['main']
6+
tags:
7+
- 'v*'
68

79
env:
810
REGISTRY: ghcr.io
911
IMAGE_NAME: ${{ github.repository }}
1012

1113
jobs:
12-
build-and-push-image:
14+
build-and-push-image-testing:
1315
runs-on: ubuntu-latest
1416
permissions:
1517
contents: read
@@ -31,18 +33,60 @@ jobs:
3133
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
3234
with:
3335
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
36+
tags: |
37+
type=raw,value=test,enable=true
3438
3539
- name: Build and push Docker image
3640
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
3741
with:
3842
context: .
3943
push: true
44+
build-args: |
45+
BUILD_MODE=development
4046
tags: ${{ steps.meta.outputs.tags }}
4147
labels: ${{ steps.meta.outputs.labels }}
42-
48+
49+
build-and-push-image-production:
50+
runs-on: ubuntu-latest
51+
if: startsWith(github.ref, 'refs/tags/v')
52+
permissions:
53+
contents: read
54+
packages: write
55+
56+
steps:
57+
- name: Checkout repository
58+
uses: actions/checkout@v2
59+
60+
- name: Log in to the Container registry
61+
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
62+
with:
63+
registry: ${{ env.REGISTRY }}
64+
username: ${{ github.actor }}
65+
password: ${{ secrets.GITHUB_TOKEN }}
66+
67+
- name: Extract metadata (tags, labels) for Docker
68+
id: meta
69+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
70+
with:
71+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
72+
tags: |
73+
type=ref,event=tag,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
74+
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
75+
type=raw,value=test,enable=true
76+
77+
- name: Build and push Docker image
78+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
79+
with:
80+
context: .
81+
push: true
82+
build-args: |
83+
BUILD_MODE=production
84+
tags: ${{ steps.meta.outputs.tags }}
85+
labels: ${{ steps.meta.outputs.labels }}
86+
4387
deploy-testing:
4488
name: Deploy Testing
45-
needs: build-and-push-image
89+
needs: build-and-push-image-testing
4690
runs-on: [self-hosted, Linux]
4791
environment:
4892
name: Testing
@@ -55,11 +99,36 @@ jobs:
5599
steps:
56100
- name: Run docker container
57101
run: |
58-
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main
102+
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test
59103
docker stop ${{ env.CONTAITER_NAME }} || true && docker rm ${{ env.CONTAITER_NAME }} || true
60104
docker run \
61105
--detach \
62106
--restart on-failure:3 \
63107
--network=web \
64108
--name ${{ env.CONTAITER_NAME }} \
65-
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main
109+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test
110+
111+
deploy-production:
112+
name: Deploy Production
113+
needs: build-and-push-image-production
114+
if: startsWith(github.ref, 'refs/tags/v')
115+
runs-on: [self-hosted, Linux]
116+
environment:
117+
name: Production
118+
url: https://timetable.ui.profcomff.com/
119+
env:
120+
CONTAITER_NAME: com_profcomff_ui_timetable
121+
permissions:
122+
packages: read
123+
124+
steps:
125+
- name: Run docker container
126+
run: |
127+
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
128+
docker stop ${{ env.CONTAITER_NAME }} || true && docker rm ${{ env.CONTAITER_NAME }} || true
129+
docker run \
130+
--detach \
131+
--restart always \
132+
--network=web \
133+
--name ${{ env.CONTAITER_NAME }} \
134+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
FROM node:16 AS build
2+
ARG BUILD_MODE
23
WORKDIR /app
34
ADD ./package.json ./package-lock.json /app/
45
RUN npm install
56
ADD . /app
6-
RUN npm run build
7+
RUN npm run build -- --mode ${BUILD_MODE}
78

89
FROM nginx:1.21
910
ADD ./default.conf /etc/nginx/conf.d/default.conf
11+
ADD ./docker_entrypoint.sh /docker_entrypoint.sh
1012
COPY --from=build /app/dist /usr/share/nginx/html
11-
RUN export APPJS_NAME=$(cd /usr/share/nginx/html && ls js/app.*.js) \
12-
&& sed -i 's|APPJS_NAME|'${APPJS_NAME}'|g' /etc/nginx/conf.d/default.conf
13+
RUN chmod +x /docker_entrypoint.sh && /docker_entrypoint.sh

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
run:
2+
npm run serve
3+
4+
build-docker-local:
5+
docker build --build-arg BUILD_MODE=development --progress=plain -t calendar_ui:local .

default.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ server {
99
try_files $uri /index.html;
1010
}
1111

12-
location /js/app.js {
13-
return 302 https://$host/APPJS_NAME;
14-
}
12+
# location /js/app.js {
13+
# return 302 https://$host/APPJS_NAME;
14+
# }
1515

1616
error_page 500 502 503 504 /50x.html;
1717
location = /50x.html {

docker_entrypoint.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
export APPJS_NAME=$(cd /usr/share/nginx/html && ls js/app.*.js)
4+
if [ ! -z ${APPJS_NAME} ]
5+
then
6+
echo 'app.js is ${APPJS_NAME}'
7+
sed -i 's|APPJS_NAME|'${APPJS_NAME}'|g' /etc/nginx/conf.d/default.conf
8+
sed -i 's|# ||g' /etc/nginx/conf.d/default.conf
9+
else
10+
echo 'app.js is app.js, no changes'
11+
fi

src/views/Init.vue

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<template>
2-
<div class="init-background">
2+
<div class="init-background" :style="{backgroundImage: `url('${bgItem}')`}">
33
<div class="container">
44
<div class="init">
5-
<img src="https://cdn.profcomff.com/app/logo/icon_512x512.png" />
5+
<img :src= "logoItem" />
66
<h1>Добро пожаловать!</h1>
77
<p>
88
Наше приложение позволит получить доступ к сервисам для студентов ФФ
@@ -47,8 +47,9 @@ export default {
4747
},
4848
loadGroups() {
4949
var url = new URL(
50-
"https://timetable.api.test.profcomff.com/timetable/group/"
51-
);
50+
`${process.env.VUE_APP_API_TIMETABLE}/timetable/group/`
51+
), params = {limit: 0, offset: 0}
52+
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]))
5253
fetch(url)
5354
.then((response) => response.json())
5455
.then((json) => {
@@ -75,6 +76,14 @@ export default {
7576
this.loadGroups();
7677
this.$store.commit("changePage", this.pageId);
7778
},
79+
computed:{
80+
logoItem(){
81+
return `${process.env.VUE_APP_CDN}/app/logo/icon_512x512.png`;
82+
},
83+
bgItem(){
84+
return `${process.env.VUE_APP_CDN}/app/background.png`;
85+
}
86+
},
7887
data() {
7988
return {
8089
pageId: 0,
@@ -89,9 +98,7 @@ export default {
8998
.init-background {
9099
width: 100%;
91100
height: 100vh;
92-
padding-top: 66px;
93-
padding-bottom: 66px;
94-
background-image: url("https://cdn.profcomff.com/app/background.png");
101+
/* background-image: url(v-bind(bgItem)); */
95102
background-repeat: repeat;
96103
background-size: cover;
97104
background-clip: padding-box;
@@ -100,9 +107,16 @@ export default {
100107
display: flex;
101108
flex-direction: column;
102109
align-items: center;
110+
justify-content: center;
103111
padding: 10%;
112+
padding-top: 66px;
113+
padding-bottom: 66px;
104114
gap: 1em;
105115
width: 100%;
116+
height: 100%;
117+
}
118+
.container{
119+
height: 100%;
106120
}
107121
h1 {
108122
font-weight: bold;
@@ -133,6 +147,6 @@ p {
133147
img {
134148
width: 40%;
135149
height: auto;
136-
max-width: 300px;
150+
max-width: 200px;
137151
}
138152
</style>

src/views/Timetable.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default {
4646
var time_start = new Date(date);
4747
var time_end = new Date();
4848
time_end.setDate(time_start.getDate() + 1)
49-
var url = new URL(`https://timetable.api.test.profcomff.com/timetable/group/${this.groupId}`),
49+
var url = new URL(`${process.env.VUE_APP_API_TIMETABLE}/timetable/group/${this.groupId}`),
5050
params = {start: time_start.toISOString().slice(0,10), end: time_end.toISOString().slice(0,10)}
5151
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]))
5252
fetch(url)

0 commit comments

Comments
 (0)