ci: add docker files
This commit is contained in:
parent
2858629b97
commit
0fe7140380
|
@ -1,73 +0,0 @@
|
||||||
run-name: ${{ gitea.actor }}, deploy with ssh
|
|
||||||
on: [push]
|
|
||||||
|
|
||||||
env:
|
|
||||||
BUILD_PATH: "."
|
|
||||||
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Detect package manager
|
|
||||||
id: detect-package-manager
|
|
||||||
run: |
|
|
||||||
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
|
|
||||||
echo "manager=yarn" >> $GITHUB_OUTPUT
|
|
||||||
echo "command=install" >> $GITHUB_OUTPUT
|
|
||||||
echo "runner=yarn" >> $GITHUB_OUTPUT
|
|
||||||
echo "lockfile=yarn.lock" >> $GITHUB_OUTPUT
|
|
||||||
exit 0
|
|
||||||
elif [ -f "${{ github.workspace }}/package.json" ]; then
|
|
||||||
echo "manager=npm" >> $GITHUB_OUTPUT
|
|
||||||
echo "command=ci" >> $GITHUB_OUTPUT
|
|
||||||
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
|
|
||||||
echo "lockfile=package-lock.json" >> $GITHUB_OUTPUT
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
echo "Unable to determine package manager"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
- name: Setup Node
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: "20"
|
|
||||||
cache: ${{ steps.detect-package-manager.outputs.manager }}
|
|
||||||
cache-dependency-path: ${{ env.BUILD_PATH }}/${{ steps.detect-package-manager.outputs.lockfile }}
|
|
||||||
- name: Install dependencies
|
|
||||||
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
|
|
||||||
working-directory: ${{ env.BUILD_PATH }}
|
|
||||||
- name: Build with Astro
|
|
||||||
run: |
|
|
||||||
${{ steps.detect-package-manager.outputs.runner }} astro build
|
|
||||||
working-directory: ${{ env.BUILD_PATH }}
|
|
||||||
- name: Deploy to my server
|
|
||||||
uses: up9cloud/action-rsync@master
|
|
||||||
env:
|
|
||||||
HOST: ${{ secrets.HOST }}
|
|
||||||
KEY: ${{ secrets.KEY }}
|
|
||||||
TARGET: ${{ secrets.DESTINATION_FOLDER }}
|
|
||||||
|
|
||||||
VERBOSE: true
|
|
||||||
USER: ${{ secrets.USERNAME }}
|
|
||||||
ARGS: -az --exclude=/.git/
|
|
||||||
SSH_ARGS: '-p 22 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
|
||||||
SOURCE: ./dist/
|
|
||||||
|
|
||||||
PRE_SCRIPT: |
|
|
||||||
echo start at:
|
|
||||||
date -u
|
|
||||||
POST_SCRIPT: "echo done at: && date -u"
|
|
||||||
- name: Send mail
|
|
||||||
uses: appleboy/ssh-action@v1.0.3
|
|
||||||
with:
|
|
||||||
host: ${{ secrets.HOST }}
|
|
||||||
username: ${{ secrets.USERNAME }}
|
|
||||||
key: ${{ secrets.KEY }}
|
|
||||||
port: ${{ secrets.PORT }}
|
|
||||||
script: |
|
|
||||||
echo -e "Subject: Act Runner Report: ${{ job.status}}\nFrom: gitea@log101.dev\n\nJob has finished with status ${{ job.status }}\n${{ github.repository }}: [${{ github.ref }}@${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/actions)" | sendmail ffrknerdm@gmail.com
|
|
||||||
|
|
28
Dockerfile
Normal file
28
Dockerfile
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# Stage 1: Build the Astro project
|
||||||
|
FROM node:20-alpine AS builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy package.json and package-lock.json files
|
||||||
|
COPY package*.json ./
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
# Copy the rest of the application files
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Build the Astro project
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Stage 2: Serve with nginx
|
||||||
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
# Copy the built static files from the builder stage
|
||||||
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||||
|
|
||||||
|
# Copy custom nginx configuration file if needed
|
||||||
|
# COPY nginx.conf /etc/nginx/nginx.conf
|
||||||
|
|
||||||
|
# Expose port 80 to the outside world
|
||||||
|
EXPOSE 80
|
|
@ -4,8 +4,7 @@ import tailwind from "@astrojs/tailwind";
|
||||||
|
|
||||||
// https://astro.build/config
|
// https://astro.build/config
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
site: "https://log101.dev",
|
site: "https://blog.log101.dev",
|
||||||
base: "/blog",
|
|
||||||
integrations: [
|
integrations: [
|
||||||
tailwind({
|
tailwind({
|
||||||
applyBaseStyles: false,
|
applyBaseStyles: false,
|
||||||
|
|
8
docker-compose.yml
Normal file
8
docker-compose.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
version: "3.8"
|
||||||
|
|
||||||
|
services:
|
||||||
|
astro:
|
||||||
|
image: registry.log101.dev/astro-nginx:latest
|
||||||
|
ports:
|
||||||
|
- "47543:80"
|
||||||
|
restart: unless-stopped
|
Loading…
Reference in New Issue
Block a user