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

Commit

Permalink
fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya101master authored and dyakovri committed Aug 30, 2022
1 parent f0dba73 commit 634ec15
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 38 deletions.
76 changes: 73 additions & 3 deletions .github/workflows/build_and_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ name: Build, publish and deploy docker

on:
push:
branches: ['main']
branches: ["main"]
tags:
- 'v*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
build-and-push-image-testing:
name: Build and push
runs-on: ubuntu-latest
permissions:
Expand All @@ -32,18 +34,61 @@ jobs:
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=test,enable=true
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
build-args: |
BUILD_MODE=development
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

build-and-push-image-production:
name: Build and push
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=raw,value=test,enable=true
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
build-args: |
BUILD_MODE=production
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

deploy-testing:
name: Deploy Testing
needs: build-and-push-image
needs: build-and-push-image-testing
runs-on: [self-hosted, Linux]
environment:
name: Testing
Expand All @@ -64,3 +109,28 @@ jobs:
--name ${{ env.CONTAITER_NAME }} \
--network=web \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main
deploy-production:
name: Deploy Production
needs: build-and-push-image-production
if: startsWith(github.ref, 'refs/tags/v')
runs-on: [self-hosted, Linux]
environment:
name: Production
url: https://app.profcomff.com/
env:
CONTAITER_NAME: com_profcomff_app
permissions:
packages: read

steps:
- name: Run docker container
run: |
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main
docker stop ${{ env.CONTAITER_NAME }} || true && docker rm ${{ env.CONTAITER_NAME }} || true
docker run \
--detach \
--restart on-failure:3 \
--name ${{ env.CONTAITER_NAME }} \
--network=web \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM node:16 AS build
ARG BUILD_MODE
WORKDIR /app
ADD ./package.json ./package-lock.json /app/
RUN npm install
ADD . /app
RUN npm run build:webpack
RUN npm run build:webpack -- --env $BUILD_MODE

FROM nginx:1.21
ADD ./default.conf /etc/nginx/conf.d/default.conf
Expand Down
19 changes: 9 additions & 10 deletions src/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@
<meta name="importmap-type" content="systemjs-importmap" />
<meta name="import-map-overrides-domains" content="denylist:app.profcomff.com" />

<script type="systemjs-importmap">
{
"imports": {
"single-spa": "https://cdn.jsdelivr.net/npm/[email protected]/lib/system/single-spa.min.js",
"@profcomff/root-config": "/profcomff-root-config.js",
"@profcomff/navbar-element": "https://navbar.ui.profcomff.com/js/app.js",
"@profcomff/timetable-webapp": "https://timetable.ui.profcomff.com/js/app.js"
}
}
</script>
<% if (development) { %>
<script src="https://aggregator.api.test.profcomff.com/importmap.json"></script>
<% } %>
<% if (isLocal) { %>
<script src="https://aggregator.api.test.profcomff.com/importmap.json"></script>
<% } %>
<% if (production) { %>
<script src="https://aggregator.api.profcomff.com/importmap.json"></script>
<% } %>
<link rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/lib/system/single-spa.min.js" as="script">

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/import-map-overrides.js"></script>
Expand Down
24 changes: 15 additions & 9 deletions src/microfrontend-layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,23 @@
<!-- Provided by always on @profcomff/navbar-element -->
</route>
<route default>
<div style="
display: flex;
flex-flow: column;
justify-content: center;
width: 100%;
min-height: 100vh;
">
<div
style="
display: flex;
flex-flow: column;
justify-content: center;
width: 100%;
min-height: 100vh;
"
>
<div style="margin: 0 10%">
<p class="display-5" style="word-wrap: break-word;">Вы попали на страницу, которой еще не существует в приложении =(</p>
<p class="display-5" style="word-wrap: break-word">
Вы попали на страницу, которой еще не существует в приложении =(
</p>
<p></p>
<p class="display-6">Попробуйте <a href="javascript:history.go(-1)">вернуться назад</a>.</p>
<p class="display-6">
Попробуйте <a href="javascript:history.go(-1)">вернуться назад</a>.
</p>
</div>
</div>
</route>
Expand Down
32 changes: 17 additions & 15 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ const singleSpaDefaults = require("webpack-config-single-spa");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const WebpackPwaManifest = require("webpack-pwa-manifest");
const WorkboxPlugin = require('workbox-webpack-plugin');

const WorkboxPlugin = require("workbox-webpack-plugin");

module.exports = (webpackConfigEnv, argv) => {
const orgName = "profcomff";
Expand All @@ -23,6 +22,8 @@ module.exports = (webpackConfigEnv, argv) => {
template: "src/index.ejs",
templateParameters: {
isLocal: webpackConfigEnv && webpackConfigEnv.isLocal,
production: webpackConfigEnv && webpackConfigEnv.production,
development: webpackConfigEnv && webpackConfigEnv.development,
orgName,
},
}),
Expand Down Expand Up @@ -57,24 +58,25 @@ module.exports = (webpackConfigEnv, argv) => {
],
inject: false,
fingerprints: false,
ios: true
ios: true,
}),
new WorkboxPlugin.GenerateSW({
clientsClaim: true,
skipWaiting: true,
runtimeCaching: [
{
urlPattern: /.*\.profcomff\.com/,
handler: 'StaleWhileRevalidate',
},
{
// Cache google fonts
urlPattern: /^https:\/\/fonts\.(?:gstatic|googleapis)\.com/,
handler: 'StaleWhileRevalidate',
options: {
cacheName: 'google-fonts-webfonts'
}
}]
{
urlPattern: /.*\.profcomff\.com/,
handler: "StaleWhileRevalidate",
},
{
// Cache google fonts
urlPattern: /^https:\/\/fonts\.(?:gstatic|googleapis)\.com/,
handler: "StaleWhileRevalidate",
options: {
cacheName: "google-fonts-webfonts",
},
},
],
}),
],
});
Expand Down

0 comments on commit 634ec15

Please sign in to comment.