From 03f253de95d40092a6fa156edf968e06fd7fd2e4 Mon Sep 17 00:00:00 2001 From: Francesco Manzali Date: Tue, 14 May 2024 19:56:33 +0200 Subject: [PATCH] Deploy settings - See: https://github.com/Morzaram/astro-caprover-template --- .github/workflows/deploy.yml | 43 ++++++++++++++++++++++++++++++++++++ Dockerfile | 8 +++++++ captain-definition | 4 ++++ default.conf | 12 ++++++++++ 4 files changed, 67 insertions(+) create mode 100644 .github/workflows/deploy.yml create mode 100644 Dockerfile create mode 100644 captain-definition create mode 100644 default.conf diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..76b42b2 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,43 @@ +name: Build & Deploy + +on: + push: + branches: ["main"] + + pull_request: + branches: ["main"] + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [20.x] + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: "npm" + - run: npm ci + - run: npm run build --if-present + - uses: a7ul/tar-action@v1.1.0 + with: + command: c + cwd: "./" + files: | + ./dist + Dockerfile + default.conf + captain-definition + outPath: deploy.tar + + - name: Deploy App to CapRover + uses: caprover/deploy-from-github@v1.0.1 + with: + server: "${{ secrets.CAPROVER_SERVER }}" + app: "${{ secrets.CAPROVER_NAME }}" + token: "${{ secrets.CAPROVER_KEY }}" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a0b0f7c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +# production environment +FROM nginx:stable-alpine +RUN rm -rf /etc/nginx/conf.d +RUN mkdir -p /etc/nginx/conf.d +COPY ./default.conf /etc/nginx/conf.d/ +COPY ./dist /usr/share/nginx/html +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/captain-definition b/captain-definition new file mode 100644 index 0000000..04859b5 --- /dev/null +++ b/captain-definition @@ -0,0 +1,4 @@ +{ + "schemaVersion": 2, + "dockerfilePath": "./Dockerfile" +} \ No newline at end of file diff --git a/default.conf b/default.conf new file mode 100644 index 0000000..c6a436a --- /dev/null +++ b/default.conf @@ -0,0 +1,12 @@ +server { + listen 80; + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + } + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} \ No newline at end of file