mirror of
https://github.com/Kizuren/kizuren.dev.git
synced 2025-12-21 13:06:11 +01:00
Added docker support
This commit is contained in:
parent
b4437b7d62
commit
94da955185
8 changed files with 148 additions and 28 deletions
7
.dockerignore
Normal file
7
.dockerignore
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
node_modules
|
||||||
|
.git
|
||||||
|
.github
|
||||||
|
.vscode
|
||||||
|
.nuxt
|
||||||
|
.output
|
||||||
|
.data
|
||||||
65
.github/workflows/build-and-deploy.yml
vendored
Normal file
65
.github/workflows/build-and-deploy.yml
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
name: Build and Deploy
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main ]
|
||||||
|
workflow_dispatch:
|
||||||
|
release:
|
||||||
|
types: [created]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
- name: Login to GitHub Container 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:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
platforms: linux/amd64, linux/arm64/v8, linux/arm/v7
|
||||||
|
tags: ghcr.io/marcus7i/marcus7i.net:${{ github.ref_name }},ghcr.io/marcus7i/marcus7i.net:latest
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: SSH and deploy
|
||||||
|
uses: appleboy/ssh-action@master
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SSH_HOST }}
|
||||||
|
username: ${{ secrets.SSH_USERNAME }}
|
||||||
|
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
|
port: ${{ secrets.SSH_PORT }}
|
||||||
|
script: |
|
||||||
|
cd /var/www/marcus7i
|
||||||
|
|
||||||
|
# Create .env file with secrets
|
||||||
|
echo "DISCORD_WEBHOOK=${{ secrets.DISCORD_WEBHOOK }}" > .env
|
||||||
|
|
||||||
|
# Pull the latest image
|
||||||
|
docker pull ghcr.io/marcus7i/marcus7i.net:latest
|
||||||
|
|
||||||
|
# Stop and start the container
|
||||||
|
docker-compose down
|
||||||
|
docker-compose up -d
|
||||||
|
|
||||||
|
# Clean up unused images
|
||||||
|
docker image prune -f
|
||||||
36
.github/workflows/build.yml
vendored
Normal file
36
.github/workflows/build.yml
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
name: Build Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
#release:
|
||||||
|
# types: [created]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: Login to GitHub Container Registry
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
platforms: linux/amd64, linux/arm64/v8, linux/arm/v7
|
||||||
|
tags: ghcr.io/marcus7i/marcus7i:${{ github.ref_name }},ghcr.io/marcus7i/marcus7i:latest
|
||||||
27
.github/workflows/deploy.yml
vendored
27
.github/workflows/deploy.yml
vendored
|
|
@ -1,27 +0,0 @@
|
||||||
name: Deploy to Production
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ main ]
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
deploy:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: SSH and deploy
|
|
||||||
uses: appleboy/ssh-action@master
|
|
||||||
with:
|
|
||||||
host: ${{ secrets.SSH_HOST }}
|
|
||||||
username: ${{ secrets.SSH_USERNAME }}
|
|
||||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
||||||
port: ${{ secrets.SSH_PORT }}
|
|
||||||
script: |
|
|
||||||
cd /var/www/marcus7i.net
|
|
||||||
git pull
|
|
||||||
npm ci
|
|
||||||
npm run build
|
|
||||||
pm2 reload ecosystem.config.cjs || pm2 start ecosystem.config.cjs --env production --env-path=".env"
|
|
||||||
|
|
||||||
# For system restarts
|
|
||||||
pm2 save
|
|
||||||
15
Dockerfile
Normal file
15
Dockerfile
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
FROM node:20-alpine as build
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm ci
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
FROM node:20-alpine
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=build /app/.output /app/.output
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
ENV PORT=3000
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
CMD ["node", ".output/server/index.mjs"]
|
||||||
13
docker-compose-build.yml
Normal file
13
docker-compose-build.yml
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
services:
|
||||||
|
nuxt-app:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
container_name: marcus7i
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "9031:3000"
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
volumes:
|
||||||
|
- ./logs:/app/logs
|
||||||
11
docker-compose.yml
Normal file
11
docker-compose.yml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
services:
|
||||||
|
nuxt-app:
|
||||||
|
image: ghcr.io/marcus7i/marcus7i.net
|
||||||
|
container_name: marcus7i
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "9031:3000"
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
volumes:
|
||||||
|
- ./logs:/app/logs
|
||||||
|
|
@ -6,7 +6,7 @@ module.exports = {
|
||||||
exec_mode: 'cluster',
|
exec_mode: 'cluster',
|
||||||
env: {
|
env: {
|
||||||
NODE_ENV: 'production',
|
NODE_ENV: 'production',
|
||||||
PORT: 9031
|
PORT: 3000
|
||||||
},
|
},
|
||||||
watch: false,
|
watch: false,
|
||||||
max_memory_restart: '1G'
|
max_memory_restart: '1G'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue