Skip to content

Commit

Permalink
build(ci): add run_compose for docker compose builds
Browse files Browse the repository at this point in the history
  • Loading branch information
PromiseFru committed Jul 9, 2024
1 parent cbcbad4 commit 1ce3abc
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 31 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/prod-deploy.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -17,21 +17,21 @@ 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

- 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 }}
Expand All @@ -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 }}
Expand All @@ -51,7 +51,7 @@ jobs:
set -e
echo "============================"
echo "🚀 Deploy Project ..."
echo "Deploy Project ..."
echo "============================"
if ! ${{secrets.BUILD_CMD}}; then
echo "❌ Error deploying project!"
Expand Down
20 changes: 13 additions & 7 deletions .github/workflows/staging-deploy.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -33,7 +33,7 @@ jobs:
echo "==============================="
echo "========================="
echo "🚀 Building project ..."
echo "Building project ..."
echo "========================="
if ! ${{ secrets.BUILD_CMD }}; then
echo "❌ Error building project!"
Expand All @@ -42,4 +42,10 @@ jobs:
echo "==========================="
echo "✅ Project build complete"
echo "==========================="
if ! ${{ secrets.CLEANUP_CMD }}; then
echo "❌ Error cleaning up builds!"
exit 1
fi
echo "============================="
echo "✅ Cleanup complete"
echo "============================="
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

pnpm-lock.yaml
17 changes: 3 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"]
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3"

services:
blog:
blog-web:
container_name: blog-web
restart: always
build:
context: .
dockerfile: Dockerfile
Expand Down
3 changes: 3 additions & 0 deletions run_compose.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

docker compose -p staging-smswithoutborders up -d --build

0 comments on commit 1ce3abc

Please sign in to comment.