diff --git a/.github/workflows/prod-deploy.yml b/.github/workflows/prod-deploy.yml index 8679644..1b5761d 100644 --- a/.github/workflows/prod-deploy.yml +++ b/.github/workflows/prod-deploy.yml @@ -1,11 +1,11 @@ -name: 🚀 Deploy SMSWithoutBorders Blog on Server (production) +name: Deploy SMSWithoutBorders Blog on Server (production) on: push: branches: - main jobs: deploy: - name: 🚀 Execute Deployment Script on Server + name: Execute Deployment Script on Server runs-on: ubuntu-latest environment: name: production @@ -17,7 +17,7 @@ jobs: - name: Setup NodeJs uses: actions/setup-node@v4 with: - node-version: 18 + node-version: 22 - name: Create .env.local file run: echo "BASE_URL=${{ secrets.BASE_URL }}" > .env.local @@ -25,13 +25,13 @@ jobs: - name: Install Dependencies run: | npm install -g pnpm - pnpm install + pnpm install --no-lockfile - name: Build Application run: pnpm build - name: Securely Copy Artifacts to Server - uses: appleboy/scp-action@v0.1.7 + uses: appleboy/scp-action@master with: host: ${{ secrets.HOST }} username: ${{ secrets.USERNAME }} @@ -41,7 +41,7 @@ jobs: strip_components: 1 rm: true - - name: 🚀 Execute Remote SSH Commands + - name: Execute Remote SSH Commands uses: appleboy/ssh-action@master with: host: ${{ secrets.HOST }} @@ -51,7 +51,7 @@ jobs: set -e echo "============================" - echo "🚀 Deploy Project ..." + echo "Deploy Project ..." echo "============================" if ! ${{secrets.BUILD_CMD}}; then echo "❌ Error deploying project!" diff --git a/.github/workflows/staging-deploy.yml b/.github/workflows/staging-deploy.yml index 81e227a..b8edecc 100644 --- a/.github/workflows/staging-deploy.yml +++ b/.github/workflows/staging-deploy.yml @@ -1,27 +1,27 @@ -name: 🚀 Deploy SMSWithoutBorders Blog on Server (staging) +name: Deploy SMSWithoutBorders Blog on Server (staging) on: push: branches: - staging jobs: deploy: - name: 🚀 Execute Deployment Script on Server + name: Execute Deployment Script on Server runs-on: ubuntu-latest environment: name: staging url: https://staging.smswithoutborders.com:18000 steps: - - name: 🚀 Execute Remote SSH Commands + - name: Execute Remote SSH Commands uses: appleboy/ssh-action@master with: host: ${{ secrets.HOST }} username: ${{ secrets.USERNAME }} - password: ${{ secrets.PASSWORD }} + key: ${{ secrets.KEY }} script: | set -e echo "============================" - echo "🚀 Updating repository ..." + echo "Updating repository ..." echo "============================" cd ${{ secrets.PROJECT_PATH }} if ! git pull; then @@ -33,7 +33,7 @@ jobs: echo "===============================" echo "=========================" - echo "🚀 Building project ..." + echo "Building project ..." echo "=========================" if ! ${{ secrets.BUILD_CMD }}; then echo "❌ Error building project!" @@ -42,4 +42,10 @@ jobs: echo "===========================" echo "✅ Project build complete" echo "===========================" - \ No newline at end of file + if ! ${{ secrets.CLEANUP_CMD }}; then + echo "❌ Error cleaning up builds!" + exit 1 + fi + echo "=============================" + echo "✅ Cleanup complete" + echo "=============================" diff --git a/.gitignore b/.gitignore index a84107a..98f31c5 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,5 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts + +pnpm-lock.yaml diff --git a/Dockerfile b/Dockerfile index 0c703b2..ca6fd65 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,13 @@ -# build environment -FROM node:18-alpine as build +FROM node:22-alpine as build WORKDIR /app -# Install global dependencies RUN npm install -g pnpm -# Copy only necessary files -COPY package.json pnpm-lock.yaml tsconfig.json ./ +COPY package.json tsconfig.json ./ COPY scripts ./scripts -# Install dependencies -RUN pnpm install +RUN pnpm install --no-lockfile -# Build the application COPY . . ARG PORT ARG SSL_PORT @@ -21,22 +16,16 @@ RUN export PORT=${PORT} SSL_PORT=${SSL_PORT} SERVER_NAME=${SERVER_NAME} && \ ./scripts/generate_env.sh && \ pnpm build -# production environment FROM nginx:stable-alpine -# Copy built files to NGINX html directory COPY --from=build /app/out /usr/share/nginx/html -# Copy NGINX configuration template COPY nginx/nginx.conf.template /etc/nginx/conf.d/default.template -# Copy entry script COPY scripts/docker-entrypoint.sh /docker-entrypoint.sh RUN chmod +x /docker-entrypoint.sh -# Expose ports EXPOSE 80 EXPOSE 443 -# Start NGINX using entry script CMD ["/docker-entrypoint.sh"] diff --git a/docker-compose.yml b/docker-compose.yml index bd20bf6..fe9a631 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ -version: "3" - services: - blog: + blog-web: + container_name: blog-web + restart: always build: context: . dockerfile: Dockerfile diff --git a/run_compose.sh b/run_compose.sh new file mode 100755 index 0000000..c387fa2 --- /dev/null +++ b/run_compose.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker compose -p staging-smswithoutborders up -d --build \ No newline at end of file