From 8916675747dcce641c6876bad03c7fc8ea8117e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9onard=20Roch?= Date: Wed, 31 Jan 2024 14:30:32 +0100 Subject: [PATCH] added actions --- .dockerignore | 4 ++++ .github/workflows/main.yaml | 23 +++++++++++++++++++++++ Dockerfile | 15 +++++++++++++++ package.json | 4 ++-- 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 .github/workflows/main.yaml create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..7b4b34d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +build +node_modules +README.md +.github \ No newline at end of file diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..46408f4 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,23 @@ +name: publish-docker-image + +on: + push: + branches: + - master + - main + +jobs: + publish-docker-image: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Publish Docker image + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ secrets.DOCKER_HUB_USERNAME }}/ref-card-02:${{ github.sha }} + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_PASSWORD }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1788919 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM node:20-alpine AS build +ENV NODE_ENV development + +WORKDIR /app +COPY . . + +RUN npm ci +RUN npm run build + +FROM nginx:1.21-alpine as prod + +COPY --from=build /app/build /usr/share/nginx/html + +EXPOSE 80 + diff --git a/package.json b/package.json index 39db532..b7318cc 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,8 @@ }, "scripts": { "start": "react-scripts --openssl-legacy-provider start", - "build": "react-scripts build", - "test": "react-scripts test", + "build": "react-scripts --openssl-legacy-provider build", + "test": "react-scripts --openssl-legacy-provider test", "eject": "react-scripts eject" }, "eslintConfig": {