Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CICD

on:
push:
branches:
- deploy-to-ec2

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

- name: Login to Docker Hub
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}

- name: Build Docker Image
run: docker build -t integrationninjas/reactjs-app .

- name: Publish image to docker hub
run: docker push integrationninjas/reactjs-app:latest

deploy:
needs: build
runs-on: aws-ec2 # Ändern Sie dies in eine gültige Runner-Umgebung
steps:
- name: Pull image from docker hub
run: docker pull integrationninjas/reactjs-app:latest

- name: Delete Old Container
run: docker rm -f reactContainer

- name: Run docker container
run: docker run -d -p 3000:80 --name reactContainer integrationninjas/reactjs-app
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# step 1 build react app
FROM node:alpine3.18 as build
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
RUN npm run build

# step 2 server with Nginx
FROM Nginx:1.23-alpine
WORKDIR /user/share/Nginx/html
RUN rm -rf *
COPY --from=build /app/build .
EXPOSE 80
ENTRYPOINT [ "Nginx", "-g" "deamon off;"]