Skip to content

Commit c14e1dd

Browse files
committed
wip #92
1 parent 1c8b7da commit c14e1dd

File tree

5 files changed

+149
-1
lines changed

5 files changed

+149
-1
lines changed

.env.development

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VITE_CB_ENDPOINT=http://localhost:8090
1+
VITE_CB_ENDPOINT=http://coderbot.local

.github/workflows/build_frontend.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: build CoderBot frontend
5+
6+
on: push
7+
8+
jobs:
9+
build-frontend:
10+
runs-on: ubuntu-latest
11+
12+
strategy:
13+
matrix:
14+
node-version: [16.x]
15+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
- name: Use Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
cache: 'npm'
24+
- run: npm ci
25+
- run: npm run build --if-present
26+
- name: Archive dist
27+
uses: actions/upload-artifact@v3
28+
with:
29+
name: frontend-dist
30+
path: dist
31+
32+
release-frontend:
33+
runs-on: ubuntu-latest
34+
needs: build-frontend
35+
steps:
36+
- uses: actions/checkout@v3 # Checking out the repo
37+
- name: Docker meta
38+
id: meta
39+
uses: docker/metadata-action@v4
40+
with:
41+
# list of Docker images to use as base name for tags
42+
images: ghcr.io/coderbotorg/frontend
43+
# generate Docker tags based on the following events/attributes
44+
tags: |
45+
# always latest
46+
type=raw,value=latest
47+
# branch event
48+
type=ref,event=branch
49+
# tag event
50+
type=ref,event=tag
51+
# pull request event
52+
type=ref,event=pr
53+
# push event
54+
type=sha,enable=true,prefix=git-,format=short
55+
- name: Download dist artifact
56+
uses: actions/download-artifact@v3
57+
with:
58+
name: frontend-dist
59+
path: frontend/dist
60+
- run: wget https://github.com/CoderBotOrg/docs/releases/download/v0.1/docs.tgz
61+
- run: mkdir -p frontend/cb_docs
62+
- run: tar xzf docs.tgz -C frontend/cb_docs
63+
- run: rm docs.tgz
64+
- name: Set up QEMU
65+
uses: docker/setup-qemu-action@v2
66+
- name: Set up Docker Buildx
67+
id: buildx
68+
uses: docker/setup-buildx-action@v2
69+
- name: Login to DockerHub
70+
uses: docker/login-action@v2
71+
with:
72+
registry: ghcr.io
73+
username: ${{ github.actor }}
74+
password: ${{ secrets.GITHUB_TOKEN }}
75+
- name: Build and push
76+
uses: docker/build-push-action@v3
77+
with:
78+
push: true
79+
platforms: linux/arm/v7
80+
tags: ${{ steps.meta.outputs.tags }}
81+
context: .
82+
file: docker/Dockerfile
83+
cache-from: type=registry,ref=ghcr.io/coderbotorg/frontend:latest
84+
cache-to: type=inline

docker/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM nginx:1.23.1-alpine
2+
3+
ADD dist /usr/share/nginx/html
4+
ADD cb_docs /usr/share/nginx/html/docs
5+
ADD docker/nginx.conf /etc/nginx/nginx.conf
6+
ADD docker/default.conf /etc/nginx/conf.d/default.conf

docker/default.conf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
server {
2+
listen 80;
3+
server_name localhost;
4+
#access_log /var/log/nginx/host.access.log main;
5+
6+
location / {
7+
root /usr/share/nginx/html;
8+
index index.html index.htm;
9+
}
10+
11+
#error_page 404 /404.html;
12+
13+
# redirect server error pages to the static page /50x.html
14+
#
15+
error_page 500 502 503 504 /50x.html;
16+
location = /50x.html {
17+
root /usr/share/nginx/html;
18+
}
19+
20+
location /api {
21+
proxy_pass http://127.0.0.1:5000;
22+
}
23+
location /wifi {
24+
rewrite /wifi/(.*) /$1 break;
25+
proxy_pass http://127.0.0.1:8080;
26+
}
27+
}

docker/nginx.conf

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
user nginx;
2+
worker_processes 1;
3+
4+
error_log /var/log/nginx/error.log notice;
5+
pid /var/run/nginx.pid;
6+
7+
8+
events {
9+
worker_connections 1024;
10+
}
11+
12+
13+
http {
14+
include /etc/nginx/mime.types;
15+
default_type application/octet-stream;
16+
17+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
18+
'$status $body_bytes_sent "$http_referer" '
19+
'"$http_user_agent" "$http_x_forwarded_for"';
20+
21+
access_log /var/log/nginx/access.log main;
22+
23+
sendfile on;
24+
#tcp_nopush on;
25+
26+
keepalive_timeout 65;
27+
28+
#gzip on;
29+
30+
include /etc/nginx/conf.d/*.conf;
31+
}

0 commit comments

Comments
 (0)