Skip to content

Commit

Permalink
chore(build): add docker
Browse files Browse the repository at this point in the history
  • Loading branch information
lhjt committed Sep 9, 2023
1 parent 3537130 commit 58a7c2b
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 10 deletions.
15 changes: 15 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*

# Panda css
styled-system/

Dockerfile
36 changes: 36 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Docker
on:
push:

jobs:
build:
name: "Build"
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
push: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/develop' }}
platforms: linux/amd64
file: Dockerfile
tags: |
ghcr.io/csesoc/maintenance-site:${{ github.sha }}
ghcr.io/csesoc/maintenance-site:latest
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM node:20-slim AS base
RUN npm i -g bun

FROM base AS deps
WORKDIR /app
COPY package.json bun.lockb ./
RUN bun i --frozen-lockfile

FROM base AS builder

WORKDIR /app
COPY package.json bun.lockb ./
RUN bun i --frozen-lockfile
COPY . .

RUN bun run build

FROM oven/bun
WORKDIR /app
COPY --from=builder /app/build .
COPY --from=deps /app/node_modules node_modules/

COPY package.json .
EXPOSE 3000
ENV NODE_ENV=production

CMD [ "bun", "index.js" ]
Binary file modified bun.lockb
Binary file not shown.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
"private": true,
"scripts": {
"dev": "vite dev",
"build": "panda codegen --clean && vite build",
"build": "svelte-kit sync && panda codegen --clean && vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --plugin-search-dir . --check . && eslint .",
"format": "prettier --plugin-search-dir . --write .",
"deps:update": "npx npm-check-updates --interactive --format group",
"panda:codegen": "panda codegen"
"svelte:sync": "svelte-kit sync",
"panda:codegen": "panda codegen",
"vite:build": "vite build"
},
"devDependencies": {
"@pandacss/dev": "0.14.0",
Expand All @@ -26,6 +28,7 @@
"prettier": "3.0.3",
"prettier-plugin-svelte": "3.0.3",
"svelte": "4.2.0",
"svelte-adapter-bun": "0.5.0",
"svelte-check": "3.5.1",
"tslib": "2.6.2",
"typescript": "5.2.2",
Expand Down
7 changes: 7 additions & 0 deletions src/routes/+layout.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { redirect } from "@sveltejs/kit";
import type { LayoutServerLoad } from "./$types";

export const load: LayoutServerLoad = (p) => {
console.log(p.url.pathname);
if (p.url.pathname !== "/") throw redirect(307, "/");
};
5 changes: 2 additions & 3 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script lang="ts">
import "../app.css";
export const prerender = true;
import "../app.css";
</script>

<slot />
<slot />
33 changes: 30 additions & 3 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
<script lang="ts">
import { } from "@/styles/typography";
import { css } from "styled-system/css";
</script>

<h1>Welcome to SvelteKit</h1>
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
<svelte:head>
<title>🚧 Page Under Maintenance</title>
<meta
name="description"
content="This page is currently under maintenance. We're sorry; please check back again soon!"
/>
</svelte:head>

<div
class={css({
height: "100vh",
width: "100vw",
display: "flex",
justifyContent: "center",
alignItems: "start",
flexDirection: "column",
p: "4rem",

maxWidth: "600px",
m: "0 auto",
})}
>
<h1 class={css({ pb: "1rem" })}>🚧 Page under maintenance</h1>
<h2 class={css({ pb: "1rem" })}>
🏗️ CSESoc's platform team is currently
<span class={css({ color: "violet.300" })}>performing maintenance</span>.
</h2>
<h3>😰 We're sorry about the inconvenience; please check back again later!</h3>
</div>
6 changes: 4 additions & 2 deletions svelte.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import adapter from "@sveltejs/adapter-static";
import { vitePreprocess } from "@sveltejs/kit/vite";
import adapter from "svelte-adapter-bun";

/** @type {import('@sveltejs/kit').Config} */
const config = {
Expand All @@ -11,7 +11,9 @@ const config = {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter(),
adapter: adapter({
fallback: "404.html",
}),
alias: {
"styled-system": "./styled-system/*",
"@/*": "./src/*",
Expand Down

0 comments on commit 58a7c2b

Please sign in to comment.