From edf96feafa51d47171ba31cf967df78df1e434ae Mon Sep 17 00:00:00 2001 From: Leonid Shestera Date: Fri, 5 Jul 2024 13:05:25 +0200 Subject: [PATCH] chore: Update Docker configuration for backend and frontend --- .github/workflows/ci.yaml | 14 +++++++++++++- Dockerfile.backend | 6 ++++-- Dockerfile.frontend | 6 ++++-- docker-bake.hcl | 16 ++++++++++++++++ 4 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 docker-bake.hcl diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6d84fe70..3996ba56 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,8 +16,20 @@ jobs: - name: Checkout code uses: actions/checkout@v2 + - name: Set up Docker + uses: docker/setup-buildx-action@v3 + + - name: Build docker containers + uses: docker/bake-action@v3 + with: + load: true + - name: Backend test run: docker compose run backend-test - name: Frontend test - run: docker compose run frontend-test \ No newline at end of file + run: docker compose run frontend-test + + - name: Cleanup + if: always() + run: docker compose down diff --git a/Dockerfile.backend b/Dockerfile.backend index 203e2b7f..f9f642ce 100644 --- a/Dockerfile.backend +++ b/Dockerfile.backend @@ -4,10 +4,12 @@ ENV NODE_ENV development WORKDIR /app -COPY . . +COPY package.json package-lock.json ./ RUN npm install +COPY . . + CMD [ "npm", "run", "dev" ] -EXPOSE 5000 \ No newline at end of file +EXPOSE 3000 \ No newline at end of file diff --git a/Dockerfile.frontend b/Dockerfile.frontend index 13e4df8a..c713cbde 100644 --- a/Dockerfile.frontend +++ b/Dockerfile.frontend @@ -4,12 +4,14 @@ ENV NODE_ENV development WORKDIR /app -COPY . . +COPY package.json package-lock.json ./ RUN npm install \ && npm i -g jest \ && npx playwright install --with-deps chromium +COPY . . + CMD [ "yarn", "start" ] -EXPOSE 5000 \ No newline at end of file +EXPOSE 3000 \ No newline at end of file diff --git a/docker-bake.hcl b/docker-bake.hcl new file mode 100644 index 00000000..7749f0da --- /dev/null +++ b/docker-bake.hcl @@ -0,0 +1,16 @@ +target "backend" { + cache-to = [ + "type=gha,ignore-error=true,mode=max,scope=backend" + ] + cache-from = [ + "type=gha,scope=backend" + ] +} +target "frontend" { + cache-to = [ + "type=gha,ignore-error=true,mode=max,scope=frontend" + ] + cache-from = [ + "type=gha,scope=frontend" + ] +}