Skip to content

Commit

Permalink
SSR (#78)
Browse files Browse the repository at this point in the history
* refactor to ssr

* update ci/cd

* add flyio hosting

* replace orderBy with toSorted

* adjust models

* more on 200 post

* finish changelog

* more on 200 post
  • Loading branch information
vorant94 authored May 5, 2024
1 parent 00d42c2 commit de79444
Show file tree
Hide file tree
Showing 282 changed files with 11,312 additions and 15,734 deletions.
1 change: 1 addition & 0 deletions .docker/proxy/example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BLOG_PORT=3000
16 changes: 16 additions & 0 deletions .docker/proxy/templates/default.conf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
upstream blog {
server blog:${BLOG_PORT};
}

server {
listen 80;
listen [::]:80;

location / {
proxy_pass http://blog;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
20 changes: 20 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
**/.idea
**/node_modules
**/dist
**/.env

**/test-results/
**/playwright-report/
**/blob-report/
**/playwright/.cache/

packages/blog/public/client/style.css
packages/blog/public/client/main.js

**/.DS_Store

.docker/*
!.docker/proxy
.docker/proxy/*
!.docker/proxy/example.env
!.docker/proxy/templates
49 changes: 17 additions & 32 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,47 @@
name: CI/CD

env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
BASE_URL: ${{ vars.BASE_URL }}

on: push

jobs:
test:
format-build-test-and-e2e:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- run: corepack enable

- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
cache: 'npm'

- run: npm ci --ignore-scripts --no-audit

- run: npm run format:check

- run: yarn
- run: npm run build:client --workspace=@digital-garden/blog

- run: yarn test
- run: npm run build:server --workspace=@digital-garden/blog

- run: yarn workspace @digital-garden/blog run e2e:setup --with-deps
- run: npm run test --workspace=@digital-garden/blog

- run: yarn workspace @digital-garden/blog run e2e
- run: npm run e2e:setup --workspace=@digital-garden/blog -- --with-deps

- run: npm run e2e --workspace=@digital-garden/blog

- uses: actions/upload-artifact@v4
with:
name: playwright-report
path: ./packages/blog/playwright-report/
retention-days: 30

- run: yarn build
if: github.ref != 'refs/heads/master'

deploy:
runs-on: ubuntu-latest
needs:
- test
if: github.ref == 'refs/heads/master'
concurrency: deploy-group
steps:
- uses: actions/checkout@v4

- run: corepack enable

- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'

- run: yarn

- run: yarn workspace @digital-garden/blog run vercel:pull --token=${{ secrets.VERCEL_TOKEN }}

- run: yarn workspace @digital-garden/blog run vercel:build --token=${{ secrets.VERCEL_TOKEN }}
- uses: superfly/flyctl-actions/setup-flyctl@master

- run: yarn workspace @digital-garden/blog run vercel:deploy --token=${{ secrets.VERCEL_TOKEN }}
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
24 changes: 9 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
**/.idea
**/node_modules
**/dist
# despite the fact that this codegen dir should be git ignored, it still needs to be indexed by IDEA
# to property inherit types of built-in Astro Collection helpers
**/.astro
**/.vercel
**/.env

**/test-results/
**/playwright-report/
**/blob-report/
**/playwright/.cache/

packages/blog/src/content/.obsidian
packages/blog/src/content/templates

# Yarn
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
packages/blog/public/client/style.css
packages/blog/public/client/main.js

**/.DS_Store

.docker/*
!.docker/proxy
.docker/proxy/*
!.docker/proxy/example.env
!.docker/proxy/templates
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn format:check
npm run format:check
5 changes: 5 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run build:server --workspace=@digital-garden/blog
npm run test --workspace=@digital-garden/blog
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.12.2
18 changes: 9 additions & 9 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
**/.idea
**/node_modules
**/dist
# despite the fact that this codegen dir should be git ignored, it still needs to be indexed by IDEA
# to property inherit types of built-in Astro Collection helpers
**/.astro
**/.vercel
**/.env

**/test-results/
**/playwright-report/
**/blob-report/
**/playwright/.cache/

packages/blog/src/content/.obsidian
packages/blog/public/client/style.css
packages/blog/public/client/main.js

# Yarn
.pnp.*
.yarn/*
**/.DS_Store

**/.DS_Store=
.docker/*
!.docker/proxy
.docker/proxy/*
!.docker/proxy/example.env
!.docker/proxy/templates
10 changes: 0 additions & 10 deletions .prettierrc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,7 @@ export default {
singleAttributePerLine: true,
plugins: [
'prettier-plugin-tailwindcss',
'prettier-plugin-astro',
'prettier-plugin-organize-imports',
'prettier-plugin-astro-organize-imports',
'prettier-plugin-css-order',
],
overrides: [
{
files: '*.astro',
options: {
parser: 'astro',
},
},
],
};
893 changes: 0 additions & 893 deletions .yarn/releases/yarn-4.1.0.cjs

This file was deleted.

2 changes: 0 additions & 2 deletions .yarnrc.yml

This file was deleted.

21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
services:
proxy:
image: nginx:1.25-alpine
container_name: proxy
hostname: proxy
restart: unless-stopped
env_file: ./.docker/proxy/.env
ports:
- '80:80'
volumes:
- './.docker/proxy/templates:/etc/nginx/templates'
depends_on:
- blog

blog:
build:
dockerfile: ./packages/blog/Dockerfile
container_name: blog
hostname: blog
restart: unless-stopped
env_file: ./packages/blog/.env
22 changes: 22 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
app = 'digital-garden-blog'
primary_region = 'waw'

[build]
dockerfile = "./packages/blog/Dockerfile"

[env]
NODE_ENV = "production"
PORT = 3000
BASE_URL = "https://www.vorant94.io"

[http_service]
internal_port = 3000
force_https = true
auto_stop_machines = false
auto_start_machines = false
processes = ['app']

[[vm]]
memory = '1gb'
cpu_kind = 'shared'
cpus = 1
Loading

0 comments on commit de79444

Please sign in to comment.