Skip to content

Commit

Permalink
update docker file arg
Browse files Browse the repository at this point in the history
  • Loading branch information
GayChin committed Apr 3, 2024
1 parent 0d3cacc commit 2397b7d
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 79 deletions.
42 changes: 21 additions & 21 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
name: CD Pipeline

on:
workflow_run:
workflows: ['CI Pipeline']
branches:
- staging
types:
- completed

jobs:
build:
runs-on: [self-hosted, oracle-vps]

steps:
- name: Pull Docker image
run: sudo docker pull ${{ secrets.DOCKER_USERNAME }}/like-minded-fe-staging:latest
- name: Delete Old docker container
run: sudo docker rm -f like-minded-fe-staging-container || true
- name: Run Docker Container
run: sudo docker run -d -p 3000:3000 --name like-minded-fe-staging-container ${{ secrets.DOCKER_USERNAME }}/like-minded-fe-staging:latest
name: CD Pipeline

on:
workflow_run:
workflows: ['CI Pipeline']
branches:
- staging
types:
- completed

jobs:
build:
runs-on: [self-hosted, oracle-vps]

steps:
- name: Pull Docker image
run: sudo docker pull ${{ secrets.DOCKER_USERNAME }}/like-minded-fe-staging:latest
- name: Delete Old docker container
run: sudo docker rm -f like-minded-fe-staging-container || true
- name: Run Docker Container
run: sudo docker run -d -p 3000:3000 --name like-minded-fe-staging-container ${{ secrets.DOCKER_USERNAME }}/like-minded-fe-staging:latest
116 changes: 58 additions & 58 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
name: CI Pipeline

on:
push:
branches:
- staging

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20.10.0

- name: Install Dependencies
run: npm install

- name: Build Next.js App
run: npm run build

docker:
runs-on: ubuntu-latest

needs: build
name: Build NextJS docker image
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to docker hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
target: dev
platforms: linux/amd64,linux/arm64/v8
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/like-minded-fe-staging:latest
build-args: |
NEXT_PUBLIC_API_ENDPOINT=${{ secrets.NEXT_PUBLIC_API_ENDPOINT }}
NEXT_PUBLIC_WS_ENDPOINT=${{ secrets.NEXT_PUBLIC_WS_ENDPOINT }}
name: CI Pipeline

on:
push:
branches:
- staging

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20.10.0

- name: Install Dependencies
run: npm install

- name: Build Next.js App
run: npm run build

docker:
runs-on: ubuntu-latest

needs: build
name: Build NextJS docker image
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to docker hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
target: dev
platforms: linux/amd64,linux/arm64/v8
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/like-minded-fe-staging:latest
build-args: |
NEXT_PUBLIC_API_ENDPOINT=${{ secrets.NEXT_PUBLIC_API_ENDPOINT }}
NEXT_PUBLIC_WS_ENDPOINT=${{ secrets.NEXT_PUBLIC_WS_ENDPOINT }}
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ COPY package*.json ./

# Create .env.local
ARG NEXT_PUBLIC_API_ENDPOINT
ARG NEXT_PUBLIC_WS_ENDPOINT
RUN touch .env.local
RUN echo "NEXT_PUBLIC_API_ENDPOINT=$NEXT_PUBLIC_API_ENDPOINT" >> .env.local
RUN echo "NEXT_PUBLIC_WS_ENDPOINT=$NEXT_PUBLIC_WS_ENDPOINT" >> .env.local
Expand Down

0 comments on commit 2397b7d

Please sign in to comment.