Skip to content

Commit

Permalink
deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
fachrihawari committed Nov 15, 2024
1 parent 8387d0c commit 792140e
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.git
node_modules
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
NEXT_PUBLIC_BASE_URL=http://localhost:3000
NEXT_PUBLIC_BASE_URL=https://example.com
PORT=3000
21 changes: 21 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Deploy Project

on:
push:
branches:
- main # Trigger the workflow on push to main branch

jobs:
deploy:
runs-on: self-hosted
steps:
# ssh into the server
- name: SSH into server
run: |
ssh -o StrictHostKeyChecking=no root@192.168.100.4 << 'EOF'
cd /root/apps/miit
git restore .
git pull origin main
docker compose down
docker compose up -d --build
EOF
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Use the official Bun image as the base
FROM oven/bun:1.1.29-alpine

# Set the working directory
WORKDIR /app

# add curl
RUN apk update && apk add curl

# Copy package.json and bun.lockb for faster installs
COPY package.json ./
COPY bun.lockb ./

# Install dependencies
RUN bun install

# Copy the rest of the application code
COPY . .

# Build the project
RUN bun run build

# Start the Next.js server
CMD bun run start
3 changes: 3 additions & 0 deletions app/api/heartbeat/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export async function GET(_: Request) {
return new Response('OK', { status: 200 })
}
26 changes: 26 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
services:
web:
build: .
restart: always
expose:
- ${PORT}
environment:
PORT: ${PORT}
NEXT_PUBLIC_BASE_URL: "https://miit.hawari.dev"

labels:
- "traefik.enable=true"
- "traefik.http.routers.miit.rule=Host(`miit.hawari.dev`)"
- "traefik.http.routers.miit.entrypoints=web"
- "traefik.http.services.miit.loadbalancer.server.port=${PORT}"
healthcheck:
test: ["CMD-SHELL", "curl http://localhost:${PORT}/api/heartbeat"]
interval: 5s
timeout: 5s
retries: 5
networks:
- traefik-network

networks:
traefik-network:
external: true

0 comments on commit 792140e

Please sign in to comment.