diff --git a/.github/workflows/github_actions_cd.yml b/.github/workflows/github_actions_cd.yml new file mode 100644 index 0000000..ab30a0b --- /dev/null +++ b/.github/workflows/github_actions_cd.yml @@ -0,0 +1,18 @@ +name: github_actions_cd + +on: + push: + branches: ["main"] + paths-ignore: + - 'frontend/**' + +jobs: + build: + runs-on: self-hosted + steps: + - name: pull Docker image + run: sudo docker pull ${{secrets.DOCKERHUB_USERNAME}}/boarlog-backend:latest + - name: delete old docker container + run: sudo docker rm -f boarlog-backend-container || true + - name: run docker container + run: sudo docker run -d -p 8000:3000 --name boarlog-backend-container ${{secrets.DOCKERHUB_USERNAME}}/boarlog-backend diff --git a/.github/workflows/github_actions_ci.yml b/.github/workflows/github_actions_ci.yml new file mode 100644 index 0000000..3b02197 --- /dev/null +++ b/.github/workflows/github_actions_ci.yml @@ -0,0 +1,24 @@ +name: github_actions_ci + +on: + push: + branches: ["dev"] + paths-ignore: + - 'frontend/**' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Dockerhub Login + env: + DOCKER_USERNAME: ${{secrets.DOCKERHUB_USERNAME}} + DOCKER_PASSWORD: ${{secrets.DOCKERHUB_TOKEN}} + run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD + - name: Build Docker image + run: docker build -t boarlog-backend ./backend + - name: taging + run: docker tag boarlog-backend:latest ${{secrets.DOCKERHUB_USERNAME}}/boarlog-backend:latest + - name: push to Dockerhub + run: docker push ${{secrets.DOCKERHUB_USERNAME}}/boarlog-backend:latest diff --git a/backend/.dockerignore b/backend/.dockerignore new file mode 100644 index 0000000..96559f2 --- /dev/null +++ b/backend/.dockerignore @@ -0,0 +1,5 @@ +.git +.env +Dockerfile +dist +node_modules diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..d367851 --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,8 @@ +FROM node:18 +WORKDIR /app +COPY package*.json . +RUN npm install +COPY /backend . +RUN npm run build +RUN npm test +CMD npm run start:prod