From d6f3911e282400fcd13227c6504a6b5ec5f9d099 Mon Sep 17 00:00:00 2001 From: SindreKjelsrud Date: Wed, 4 Dec 2024 17:06:10 +0100 Subject: [PATCH] :green_heart: Update workflow for forgejo instance Signed-off-by: SindreKjelsrud --- .forgejo/workflows/deploy.yml | 16 ++++++++++++++ .github/workflows/deploy.yml | 41 ----------------------------------- Dockerfile | 18 +++++++++++++++ docker-compose.yml | 8 +++++++ 4 files changed, 42 insertions(+), 41 deletions(-) create mode 100644 .forgejo/workflows/deploy.yml delete mode 100644 .github/workflows/deploy.yml create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml new file mode 100644 index 0000000..c307017 --- /dev/null +++ b/.forgejo/workflows/deploy.yml @@ -0,0 +1,16 @@ +name: Deploy website + +on: + push: + branches: [ main ] + paths-ignore: + - 'README.md' # Ignore changes to README.md + +jobs: + build-and-deploy: + runs-on: docker + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Run docker-compose + run: docker compose up -d --build diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 8e2a6b6..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Deploy website - -on: - push: - branches: [ main ] - paths-ignore: - - 'README.md' # Ignore changes to README.md - # Allows you to run this workflow manually from the Actions tab on GitHub. - workflow_dispatch: - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: '21' - - - name: Install pnpm - run: npm install -g @pnpm/exe - - - name: Install dependencies - run: pnpm install - - - name: Build Astro website - run: pnpm build - - - name: Rsync files - uses: burnett01/rsync-deployments@5.2 - with: - switches: -avzr --delete - path: dist/ - remote_path: /var/www/kjelsrud.dev/ - remote_host: ${{ secrets.HOST }} - remote_user: ${{ secrets.USER }} - remote_key: ${{ secrets.KEY }} - remote_port: ${{ secrets.PORT }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8a3721c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM node:lts-alpine AS build + +WORKDIR /app + +RUN npm install -g pnpm + +COPY . /app + +RUN pnpm install +RUN pnpm run build + +FROM caddy:alpine + +COPY --from=build /app/dist /usr/share/caddy + +EXPOSE 4321 + +CMD ["caddy", "file-server", "--root", "/usr/share/caddy", "--listen", ":4321"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..38c3748 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +services: + web: + restart: always + build: + context: . + dockerfile: Dockerfile + ports: + - "4321:4321"