Skip to content

Commit

Permalink
chore(website): drop GitHub Pages (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
wellwelwel authored Feb 23, 2024
1 parent 6b1bcff commit 38fe14b
Show file tree
Hide file tree
Showing 15 changed files with 402 additions and 3 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ on:
- 'website/**'
workflow_dispatch:

env:
SRV_HOST: ${{secrets.SRV_HOST}}
SRV_USER: ${{secrets.SRV_USER}}
SRV_PORT: ${{secrets.SRV_PORT}}
SRV_PASS: ${{secrets.SRV_PASS}}
APP_PORT: ${{secrets.APP_PORT}}

jobs:
deploy:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -43,3 +50,6 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./website/build

- name: Deploy
run: cd website && npm run deploy
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
.DS_Store
/lib
/ci
.env
5 changes: 5 additions & 0 deletions website/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SRV_HOST=""
SRV_USER=""
SRV_PASS=""
SRV_PORT=
APP_PORT=
1 change: 1 addition & 0 deletions website/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/build
/.docusaurus
/.cache-loader
/.svps
2 changes: 2 additions & 0 deletions website/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

# Production
/build
/.svps
.env

# Generated files
.docusaurus
Expand Down
2 changes: 1 addition & 1 deletion website/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/build
/.docusaurus
/.cache-loader
# /**/*.mdx
/.svps
8 changes: 8 additions & 0 deletions website/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM oven/bun:alpine

WORKDIR /usr/app

COPY ./build ./build
COPY ./server.ts ./server.ts

CMD ["bun", "server.ts"]
13 changes: 13 additions & 0 deletions website/deploy/access.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'dotenv/config';
import { SVPS } from 'svps';

const { SRV_HOST, SRV_PORT, SRV_USER, SRV_PASS } = process.env;

export const svps = new SVPS({
access: {
host: String(SRV_HOST),
port: Number(SRV_PORT),
username: String(SRV_USER),
password: String(SRV_PASS),
},
});
27 changes: 27 additions & 0 deletions website/deploy/mount-server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'dotenv/config';
import { exit } from 'poku';
import { svps } from './access.js';

(async () => {
const mounted = await svps.mount({
repair: true,
apt: true,
apache: true,
docker: true,
firewall: true,
});

const createdVH =
mounted &&
(await svps.createVirtualHosts([
{
domain: 'poku.dev',
port: Number(process.env.APP_PORT),
www: true,
},
]));

await svps.end();

exit(createdVH ? 0 : 1);
})();
34 changes: 34 additions & 0 deletions website/deploy/upload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import 'dotenv/config';
import { svps } from './access.js';
import { exit } from 'poku';

(async () => {
const port = process.env.APP_PORT;

const uploaded = await svps.upload([
{
local: './server.ts',
remote: 'server.ts',
},
{
local: './build',
remote: './',
},
{
local: './Dockerfile',
remote: 'Dockerfile',
},
{
local: './docker-compose.yml',
remote: 'docker-compose.yml',
},
]);

const composed =
uploaded &&
(await svps.commands([`APP_PORT=${port} docker compose up --build -d`]));

await svps.end();

exit(composed ? 0 : 1);
})();
10 changes: 10 additions & 0 deletions website/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '3.9'
services:
server:
build: .
container_name: poku-website
restart: always
ports:
- '127.0.0.1:${APP_PORT}:${APP_PORT}'
environment:
APP_PORT: ${APP_PORT}
2 changes: 1 addition & 1 deletion website/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const config: Config = {
containerId: 'GTM-K554VSWG',
},
gtag: {
trackingID: 'G-GKVD8FM0B0',
trackingID: 'G-3EXQWTDQSK',
anonymizeIP: true,
},
} satisfies Preset.Options,
Expand Down
Loading

0 comments on commit 38fe14b

Please sign in to comment.