Skip to content

Commit

Permalink
ssh deploy w/ docker and nginx conf
Browse files Browse the repository at this point in the history
  • Loading branch information
aenriii committed Dec 30, 2023
1 parent f16c18c commit 8b98869
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.svelte-kit
bun.lockb
34 changes: 34 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Deploy to SSH server
on:
push:
branches:
- main
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
environment: SSH Deploy
steps:
- uses: actions/checkout@v2

- name: Set up SSH
run: |
mkdir -p ~/.ssh/
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -t rsa ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Deploy over SSH
run: |
ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -p ${{ secrets.SSH_PORT }} "cd ${{ secrets.SSH_PATH }} && git pull origin main && ${{ secrets.DEPLOY_COMMAND }}"
# required secrets:
# SSH_HOST
# SSH_USER gh-actions
# SSH_PORT 22
# SSH_PATH ~aenri/stack/aenri.loveh.art
# SSH_PRIVATE_KEY
# DEPLOY_COMMAND sudo bash -c "docker compose down -v --remove-orphans && docker compose up -d --build --wait && ../update"
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM oven/bun:latest

# ENV ADDRESS_HEADER="X-Forwarded-For"
# ENV PROTOCOL_HEADER="X-Forwarded-Proto"
ENV HOST_HEADER="Host"

COPY . .

RUN bun i --no-cache -f --no-save

RUN bun run build

CMD [ "bun", "run", "./server/index.js" ]
Binary file modified bun.lockb
Binary file not shown.
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3'
services:
app:
build:
context: .
restart: unless-stopped
container_name: aenri-site
networks:
- nginx

networks:
nginx:
external: true
7 changes: 7 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
server {
listen 80;
server_name aenri.loveh.art;
location / {
proxy_pass http://aenri-site
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@catppuccin/palette": "^0.2.0",
"@emotion/css": "^11.11.2",
"@sveltejs/adapter-cloudflare": "^3.0.1",
"sass": "^1.69.5"
"sass": "^1.69.5",
"svelte-adapter-bun": "^0.5.1"
}
}
3 changes: 1 addition & 2 deletions src/components/PageHost.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
@media (min-width: 768px) {
min-height: calc(100vh - 100px);
max-height: calc(100vh - 100px);
width: calc(100vw - 100px);
max-width: calc(100vw - 100px);
padding: 50px;
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/ProfileCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
flex: 1;
min-height: 100%;
background: center 150px / 100% auto linear-gradient(180deg, #FFABAC 0%, #FF2BA7 99.94%) no-repeat,
center -180px / 120% auto url("banner.png") no-repeat;
center -180px / 120% auto url("/banner.png") no-repeat;
border-radius: 50px;
}
Expand All @@ -59,7 +59,7 @@
#avatar-inner {
width: 100px;
height: 100px;
background: center / contain no-repeat url("avatar.png");
background: center / contain no-repeat url("/avatar.png");
border-radius: 100px;
}
#name {
Expand Down
1 change: 0 additions & 1 deletion src/components/parts/ProjectCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
/>
*/
console.log("ProjectCard: ", name, description, icon, status, githubLink, codebergLink, discordLink);
</script>

<style lang="scss">
Expand Down
3 changes: 3 additions & 0 deletions src/routes/healthcheck/+server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { RequestHandler } from "./$types";

export const GET: RequestHandler = () => new Response("Ok!");
7 changes: 5 additions & 2 deletions svelte.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import adapter from '@sveltejs/adapter-cloudflare';
import adapter from 'svelte-adapter-bun';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

/** @type {import('@sveltejs/kit').Config} */
Expand All @@ -11,7 +11,10 @@ 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({
out: 'server',
precompress: false,
})
}
};

Expand Down

0 comments on commit 8b98869

Please sign in to comment.