Skip to content

Commit df178b0

Browse files
committed
initial commit
1 parent 25d5167 commit df178b0

File tree

76 files changed

+7485
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+7485
-0
lines changed

.dockerignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# ---------------------------------------------------------------------------------*
2+
# This will prevent your local modules and debug logs from being copied onto your
3+
# Docker image and possibly overwriting modules installed within your image.
4+
# ---------------------------------------------------------------------------------*
5+
node_modules
6+
npm-debug.log
7+
# ignore .git and .cache folders
8+
.git
9+
.cache
10+
# ignore all markdown files (md) beside all README*.md other than README-secret.md
11+
*.md
12+
!README*.md
13+
README-secret.md
14+
# github related files
15+
.github/

.env

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
NEXT_PUBLIC_PORT = 8080
2+
NEXT_PUBLIC_START_PAGE = /README.md
3+
4+
# Environment variables for CSCode HttpYac REST Client.
5+
env_tokenEndpoint={{oidc}}
6+
env_clientId={{clientId}}
7+
env_clientSecret={{clientSecret}}
8+
env_username={{userName}}
9+
env_password={{password}}

.github/workflows/docs-local.yml

+153
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
name: Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
name: Build & Publish 🚀
12+
runs-on: self-hosted
13+
env:
14+
INPUTPATH: asciidocs
15+
OUTPUTPATH: dist
16+
SLIDES: true
17+
BRANCH: gh-pages
18+
steps:
19+
- name: Checkout repo
20+
uses: actions/checkout@v4
21+
- name: Build
22+
uses: quirinecker/asciidoctor-convert-action@main
23+
with:
24+
slides: ${{ env.SLIDES }}
25+
inputPath: ${{ env.INPUTPATH }}
26+
outputPath: ${{ env.OUTPUTPATH }}
27+
- name: Deploy to GitHub Pages
28+
uses: JamesIves/github-pages-deploy-action@releases/v4
29+
with:
30+
TOKEN: ${{ github.TOKEN }}
31+
BRANCH: ${{ env.BRANCH }}
32+
FOLDER: ${{ env.OUTPUTPATH }}
33+
bump:
34+
name: Get And Bump SemVer 👊
35+
runs-on: self-hosted
36+
needs: [build]
37+
steps:
38+
- name: Checkout repo
39+
uses: actions/checkout@v4
40+
with:
41+
fetch-depth: '0'
42+
- name: Bump version and push tag
43+
uses: anothrNick/github-tag-action@master
44+
env:
45+
GITHUB_TOKEN: ${{ github.TOKEN }}
46+
RELEASE_BRANCHES: master
47+
DEFAULT_BUMP: patch
48+
WITH_V: false
49+
docker-build:
50+
name: Build Docker Image 🐋
51+
runs-on: self-hosted
52+
needs: [bump]
53+
steps:
54+
- name: Checkout repo
55+
uses: actions/checkout@v4
56+
- name: Checkout site
57+
uses: actions/checkout@v4
58+
with:
59+
ref: gh-pages
60+
path: site
61+
- name: Touch .env file
62+
run: touch site/.env
63+
- name: Fill .env file
64+
run: |
65+
echo NEXT_PUBLIC_PORT=${{ secrets.PORT }} >> site/.env
66+
echo NEXT_PUBLIC_START_PAGE=${{ secrets.START_PAGE }} >> site/.env
67+
echo NEXT_PUBLIC_PLANTUML_URL=${{ secrets.PLANTUML_URL }} >> site/.env
68+
echo NEXT_PUBLIC_SERVER_URL=${{ secrets.SERVER_URL }} >> site/.env
69+
echo NEXT_PUBLIC_IS_APP_FOLDER=true >> site/.env
70+
- name: Touch keycloak.json file
71+
run: touch site/keycloak.json
72+
- name: Fill keycloak.json file
73+
run: |
74+
cat <<EOF >> site/keycloak.json
75+
${{ secrets.KEYCLOAK_FILE }}
76+
EOF
77+
- name: Setup QEMU
78+
uses: docker/setup-qemu-action@v3
79+
- name: Set up Docker Buildx
80+
uses: docker/setup-buildx-action@v3
81+
82+
- name: Login to DockerHub
83+
uses: docker/login-action@v3
84+
with:
85+
username: ${{ secrets.DOCKER_HUB_USER }}
86+
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
87+
- name: Build and push
88+
uses: docker/build-push-action@v5
89+
with:
90+
context: ./
91+
file: ./Dockerfile
92+
platforms: linux/amd64,linux/arm64/v8
93+
push: true
94+
tags: ${{ secrets.DOCKER_HUB_USER }}/safe-learn:latest
95+
deploy:
96+
name: Deployment 💻
97+
runs-on: self-hosted
98+
needs: [docker-build]
99+
steps:
100+
- name: Checkout repo
101+
uses: actions/checkout@v4
102+
- name: Install OpenVPN
103+
run: |
104+
sudo apt update
105+
sudo apt install -y openvpn openvpn-systemd-resolved
106+
- name: Touch OVPN client-config file
107+
run: touch client.ovpn
108+
- name: Fill OVPN client-config file
109+
run: |
110+
echo "${{ secrets.VPN_OVPN_FILE }}" >> client.ovpn
111+
- name: Connect to VPN 🔓
112+
uses: "kota65535/github-openvpn-connect-action@v3"
113+
with:
114+
config_file: client.ovpn
115+
username: ${{ secrets.VPN_USERNAME }}
116+
password: ${{ secrets.VPN_PASSWORD }}
117+
- name: Installing SSH key 🔑
118+
uses: UnterrainerInformatik/setup-ssh-action@v1
119+
with:
120+
key: ${{ secrets.DEPLOY_SSH_PRIVATE_KEY }}
121+
- name: Create deploy directory 🚧
122+
uses: UnterrainerInformatik/ssh-mkdir-action@v1
123+
with:
124+
dir: /app/deploy/${{ secrets.DEPLOY_DIR }}
125+
user: ${{ secrets.DEPLOY_SSH_USER }}
126+
host: ${{ secrets.DEPLOY_SERVER }}
127+
port: ${{ secrets.DEPLOY_SSH_PORT }}
128+
- name: Create data directory 🚧
129+
uses: UnterrainerInformatik/ssh-mkdir-action@v1
130+
with:
131+
dir: /app/data/${{ secrets.DEPLOY_DIR }}
132+
user: ${{ secrets.DEPLOY_SSH_USER }}
133+
host: ${{ secrets.DEPLOY_SERVER }}
134+
port: ${{ secrets.DEPLOY_SSH_PORT }}
135+
- name: Deploy using SSH 🚛
136+
uses: UnterrainerInformatik/ssh-deploy-action@v1
137+
with:
138+
source: ./deploy
139+
target: /app/deploy/${{ secrets.DEPLOY_DIR }}
140+
chmod-mask: 777
141+
chmod-selector: ./deploy/*.sh
142+
user: ${{ secrets.DEPLOY_SSH_USER }}
143+
host: ${{ secrets.DEPLOY_SERVER }}
144+
port: ${{ secrets.DEPLOY_SSH_PORT }}
145+
- name: Run using SSH 🏃
146+
uses: UnterrainerInformatik/ssh-run-action@v1
147+
with:
148+
dir: /app/deploy/${{ secrets.DEPLOY_DIR }}
149+
file: up.sh
150+
user: ${{ secrets.DEPLOY_SSH_USER }}
151+
host: ${{ secrets.DEPLOY_SERVER }}
152+
port: ${{ secrets.DEPLOY_SSH_PORT }}
153+

.gitignore

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
# Created by https://www.toptal.com/developers/gitignore/api/macos
3+
# Edit at https://www.toptal.com/developers/gitignore?templates=macos
4+
5+
### macOS ###
6+
# General
7+
.DS_Store
8+
.AppleDouble
9+
.LSOverride
10+
11+
# Icon must end with two \r
12+
Icon
13+
14+
15+
# Thumbnails
16+
._*
17+
18+
# Files that might appear in the root of a volume
19+
.DocumentRevisions-V100
20+
.fseventsd
21+
.Spotlight-V100
22+
.TemporaryItems
23+
.Trashes
24+
.VolumeIcon.icns
25+
.com.apple.timemachine.donotpresent
26+
/keycloak*
27+
httpyac.config.cjs
28+
29+
# Directories potentially created on remote AFP share
30+
.AppleDB
31+
.AppleDesktop
32+
Network Trash Folder
33+
Temporary Items
34+
.apdisk
35+
.obsidian
36+
node_modules
37+
38+
# End of https://www.toptal.com/developers/gitignore/api/macos
39+
40+
dist
41+
docs/slides/revealjs
42+
.idea/
43+
*.jar
44+
*.zip

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20

.vscode/launch.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "chrome",
6+
"request": "launch",
7+
"name": "Launch secureLectures",
8+
"url": "http://localhost:8080",
9+
"webRoot": "${workspaceFolder}"
10+
},
11+
{
12+
"type": "node",
13+
"request": "launch",
14+
"name": "Launch Node.js",
15+
"program": "${workspaceFolder}/app.js"
16+
}
17+
],
18+
"compounds": [
19+
{
20+
"name": "Debug secureLectures and Node.js",
21+
"configurations": ["Launch secureLectures", "Launch Node.js"]
22+
}
23+
]
24+
}

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"asciidoc.antora.enableAntoraSupport": false
3+
}

Dockerfile

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM node
2+
# update dependencies and install curl
3+
RUN apt-get update && apt-get install -y \
4+
curl \
5+
&& rm -rf /var/lib/apt/lists/*
6+
# Create app directory
7+
WORKDIR /app
8+
FROM node:alpine
9+
10+
# Make app directory in the container.
11+
RUN mkdir /app
12+
13+
# Copy whole code to app directory.
14+
COPY site/ /app
15+
# Copy MD directory to app directory.
16+
COPY md/ /app/md
17+
# Copy the assets folder to app directory.
18+
COPY assets/ /app/assets
19+
# Copy the middlewares folder to app directory.
20+
COPY middlewares/ /app/middlewares
21+
22+
# Copy package.json app directory.
23+
COPY package.json /app
24+
COPY package-lock.json /app
25+
COPY *.js /app
26+
COPY *.css /app
27+
28+
# make app directory as the working directory.
29+
WORKDIR /app
30+
31+
# Install dependencies.
32+
RUN npm install -only=production
33+
34+
# Expose the port
35+
EXPOSE 8080
36+
37+
# Start the process
38+
CMD ["npm", "run", "prod"]

0 commit comments

Comments
 (0)