File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Deploy Node Application
2+
3+ on :
4+ push :
5+ branches :
6+ - mern-ec2-docker-ssl
7+
8+ jobs :
9+ build :
10+ runs-on : ubuntu-latest
11+ steps :
12+ - name : Checkout Source
13+ uses : actions/checkout@v4
14+ - name : Login to docker hub
15+ run : docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
16+ - name : Build Docker Image
17+ run : docker build -t integrationninjas/nodejs-app .
18+ - name : Publish Image to docker hub
19+ run : docker push integrationninjas/nodejs-app:latest
20+
21+ deploy :
22+ needs : build
23+ runs-on : self-hosted
24+ steps :
25+ - name : Pull image from docker hub
26+ run : docker pull integrationninjas/nodejs-app:latest
27+ - name : Delete old container
28+ run : docker rm -f nodejs-app-container
29+ - name : Run Docker Container
30+ run : docker run -d -p 4000:4000 --name nodejs-app-container -e MONGO_PASSWORD='${{ secrets.MONGO_PASSWORD }}' integrationninjas/nodejs-app
Original file line number Diff line number Diff line change 1+ FROM node:alpine3.18
2+ WORKDIR /app
3+ COPY package.json ./
4+ RUN npm install
5+ COPY . .
6+ EXPOSE 4000
7+ CMD [ "npm" , "run" , "start" ]
You can’t perform that action at this time.
0 commit comments