From 1310639bc542be1c7f476bdba54e709fd880eb70 Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Thu, 17 Oct 2024 14:49:30 +0800 Subject: [PATCH] vault backup: 2024-10-17 14:49:30 --- .woodpecker/.build.yml | 11 +++++++++++ .woodpecker.yml => .woodpecker/.deploy.yml | 14 ++++++++------ Dockerfile | 22 ++++++++++++++++++++++ README.md | 2 +- nginx/nginx.conf | 13 +++++++++++++ 5 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 .woodpecker/.build.yml rename .woodpecker.yml => .woodpecker/.deploy.yml (65%) create mode 100644 Dockerfile create mode 100644 nginx/nginx.conf diff --git a/.woodpecker/.build.yml b/.woodpecker/.build.yml new file mode 100644 index 0000000..8b0e9d6 --- /dev/null +++ b/.woodpecker/.build.yml @@ -0,0 +1,11 @@ +steps: + - name: build + image: node:18-alpine + when: + - branch: master + event: push + commands: + - docker build . -t "$IMAGE" + - echo "$REGISTRY_PASSWORD" | docker login "$REGISTRY" --password-stdin -u "$REGISTRY_USERNAME" + - docker push "$IMAGE" + secrets: [REGISTRY, REGISTRY_USERNAME, REGISTRY_PASSWORD, IMAGE] diff --git a/.woodpecker.yml b/.woodpecker/.deploy.yml similarity index 65% rename from .woodpecker.yml rename to .woodpecker/.deploy.yml index 34c4a7b..fe87fc7 100644 --- a/.woodpecker.yml +++ b/.woodpecker/.deploy.yml @@ -1,7 +1,6 @@ -# .woodpecker.yml steps: - - name: build & copy - image: node:18-alpine + - name: deploy + image: alpine:3.20.3 when: - branch: master event: push @@ -11,7 +10,10 @@ steps: - echo "$SSH_KEY" | tr -d '\r' > /root/.ssh/id_rsa - chmod 600 /root/.ssh/id_rsa - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > /root/.ssh/config - - npm install - - npm run build - - scp -r build/* "$REMOTE_HOST:$PROJECT_DIRECTORY" + - ssh -r "$REMOTE_HOST" 'cd "$PROJECT_DIRECTORY"; + docker-compose down; + docker-compose up;' secrets: [SSH_KEY, REMOTE_HOST, PROJECT_DIRECTORY] + +depends_on: + - build diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..857ba68 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM node:18-alpine as build + +WORKDIR /usr/local/app + +COPY ./ /usr/local/app/ + +RUN npm install + +RUN npm run build + + +FROM nginx:latest + +RUN rm -rf /usr/share/nginx/html/* + +COPY --from=build /usr/local/app/ /usr/share/nginx/html + +COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf + +RUN service nginx restart + +EXPOSE 80 diff --git a/README.md b/README.md index 151c60d..3ab0a29 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![Build Status](https://woodpecker.06222001.xyz/api/badges/5/status.svg) +![Build Status](https://woodpecker.06222001.xyz/api/badges/1/status.svg) ![Site Status](https://stats.keannu5.duckdns.org/api/badge/122/status) A GitHub mirror of my [Obsidian](https://obsidian.md/) blog posts, guides, and public notes. diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 0000000..a233174 --- /dev/null +++ b/nginx/nginx.conf @@ -0,0 +1,13 @@ +server { + listen 80; + sendfile on; + default_type application/octet-stream; + server_name angularfrontend.lemnsea-fab4664b.westus3.azurecontainerapps.io; + gzip on; + + root /usr/share/nginx/html/dist/simpledmca-web/browser; + + location / { + try_files $uri $uri/ /index.html =404; + } +} \ No newline at end of file