From d99a6e6fcfdceb032405a253de572c62875d20c8 Mon Sep 17 00:00:00 2001 From: Paulo V T Silva Date: Fri, 23 Aug 2024 14:22:27 -0300 Subject: [PATCH 1/4] fix: ajust compose and env.example --- .env.example | 10 +++++----- docker-compose.yaml | 19 ++++++++++--------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.env.example b/.env.example index f2f8808..24a6ff4 100644 --- a/.env.example +++ b/.env.example @@ -4,8 +4,8 @@ SECRET_KEY='321' DATABASE_URL="postgresql://postgres:password@localhost:5432/octopost" -MONGO_INITDB_ROOT_USERNAME -MONGO_INITDB_ROOT_PASSWORD -ME_CONFIG_MONGODB_ADMINUSERNAME -ME_CONFIG_MONGODB_ADMINPASSWORD -ME_CONFIG_MONGODB_URL +MONGO_ROOT_USERNAME="octopost" +MONGO_ROOT_PASSWORD="1234" +MONGODB_ADMINUSERNAME="octopost" +MONGODB_ADMINPASSWORD="1234" +MONGODB_URL="mongodb://octopost:1234@mongo:27017" diff --git a/docker-compose.yaml b/docker-compose.yaml index 21158ee..ad9f414 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -3,32 +3,33 @@ services: container_name: octopost-db-dev profiles: - dev - image: mongo:latest + image: mongo:7.0.14-rc0-nanoserver-ltsc2022 ports: - '27017:27017' environment: - MONGO_INITDB_ROOT_USERNAME: $MONGO_INITDB_ROOT_USERNAME - MONGO_INITDB_ROOT_PASSWORD: $MONGO_INITDB_ROOT_PASSWORD + MONGO_INITDB_ROOT_USERNAME: $MONGO_ROOT_USERNAME + MONGO_INITDB_ROOT_PASSWORD: $MONGO_ROOT_PASSWORD volumes: - db:/var/lib/mongodb/mydata networks: - octopost - + mongo-express: image: mongo-express + restart: always depends_on: [db-dev] ports: - - 8081:8081 + - 3476:8081 environment: - ME_CONFIG_MONGODB_ADMINUSERNAME: $ME_CONFIG_MONGODB_ADMINUSERNAME - ME_CONFIG_MONGODB_ADMINPASSWORD: $ME_CONFIG_MONGODB_ADMINPASSWORD - ME_CONFIG_MONGODB_URL: $ME_CONFIG_MONGODB_URL + ME_CONFIG_MONGODB_ADMINUSERNAME: $MONGODB_ADMINUSERNAME + ME_CONFIG_MONGODB_ADMINPASSWORD: $MONGODB_ADMINPASSWORD + ME_CONFIG_MONGODB_URL: $MONGODB_URL ME_CONFIG_BASICAUTH: false links: - db-dev networks: - octopost - + api: build: context: ./ From 35a79e5615c9300cb12569235abb811cd0a93c0c Mon Sep 17 00:00:00 2001 From: Paulo V T Silva Date: Fri, 23 Aug 2024 14:29:24 -0300 Subject: [PATCH 2/4] feat: insert new base workflows --- .github/workflows/auto-assign.yml | 21 --------------------- .github/workflows/base-workflows.yml | 11 +++++++++++ 2 files changed, 11 insertions(+), 21 deletions(-) delete mode 100644 .github/workflows/auto-assign.yml create mode 100644 .github/workflows/base-workflows.yml diff --git a/.github/workflows/auto-assign.yml b/.github/workflows/auto-assign.yml deleted file mode 100644 index e6ef79f..0000000 --- a/.github/workflows/auto-assign.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Auto Assign Issue - -on: - issue_comment: - types: [created] - -jobs: - auto-assign: - runs-on: ubuntu-latest - steps: - - name: Check for "EU QUERO!!!" comment - if: contains(github.event.comment.body, 'EU QUERO!!!') - run: | - # Extract the commenter's username - commenter=$(jq -r .comment.user.login $GITHUB_EVENT_PATH) - - # Add the commenter as an assignee to the issue using a Personal Access Token - echo "Assigning $commenter to the issue..." - curl -X POST -H "Authorization: token ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \ - -d "{\"assignees\": [\"$commenter\"]}" \ - "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees" diff --git a/.github/workflows/base-workflows.yml b/.github/workflows/base-workflows.yml new file mode 100644 index 0000000..fa4d29e --- /dev/null +++ b/.github/workflows/base-workflows.yml @@ -0,0 +1,11 @@ +name: Base Actions + +on: + issue_comment: + types: [created] + pull_request: + +jobs: + assignes: + uses: devhatt/workflows/.github/workflows/auto-assign.yml@main + secrets: inherit From 61218e86e02e09b23e21fb8d3987a2862c6e60c6 Mon Sep 17 00:00:00 2001 From: Paulo V T Silva Date: Mon, 26 Aug 2024 14:26:22 -0300 Subject: [PATCH 3/4] fix: ajust docker compose and dockerfile --- Dockerfile | 28 +++++++++++++++++++++------- docker-compose.yaml | 26 +++++++++++++++----------- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8bc1d6d..b2a5129 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,25 +1,39 @@ -FROM node:22 AS build +FROM node:22 AS base + +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" WORKDIR /usr/src/app -RUN npm install -g pnpm@8 +RUN corepack enable && corepack prepare pnpm@8.6.0 --activate COPY ./package.json ./pnpm-lock.yaml ./ COPY ./ . -RUN pnpm install --frozen-lockfile -r +FROM base AS prod-deps + +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile + +FROM base AS build + +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile RUN npx prisma generate RUN pnpm build FROM node:22-alpine3.19 +ENV PNPM_HOME="/pnpm" +ENV PATH="$PNPM_HOME:$PATH" + + +RUN corepack enable && corepack prepare pnpm@8.6.0 --activate + + WORKDIR /usr/src/app -RUN npm install -g pnpm@8 -COPY --from=build /usr/src/app/package.json ./package.json COPY --from=build /usr/src/app/build ./build -COPY --from=build /usr/src/app/node_modules ./node_modules +COPY --from=prod-deps /usr/src/app/node_modules ./node_modules EXPOSE 3000 -CMD ["pnpm", "run", "start"] \ No newline at end of file +CMD ["pnpm", "start"] diff --git a/docker-compose.yaml b/docker-compose.yaml index ad9f414..cb19256 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,9 +1,8 @@ services: db-dev: &db - container_name: octopost-db-dev profiles: - dev - image: mongo:7.0.14-rc0-nanoserver-ltsc2022 + image: mongo:7.0.14-rc0-jammy ports: - '27017:27017' environment: @@ -14,19 +13,17 @@ services: networks: - octopost - mongo-express: + mongo-express-dev: &mg-express + profiles: + - dev image: mongo-express - restart: always - depends_on: [db-dev] ports: - - 3476:8081 + - 8081:8081 environment: ME_CONFIG_MONGODB_ADMINUSERNAME: $MONGODB_ADMINUSERNAME ME_CONFIG_MONGODB_ADMINPASSWORD: $MONGODB_ADMINPASSWORD - ME_CONFIG_MONGODB_URL: $MONGODB_URL + ME_CONFIG_MONGODB_URL: 'mongodb://octopost:1234@db-dev:27017' ME_CONFIG_BASICAUTH: false - links: - - db-dev networks: - octopost @@ -38,15 +35,22 @@ services: profiles: - prod ports: - - 3000:3000 + - '${PORT}:${PORT}' depends_on: - db-prod networks: - octopost + mongo-express-prod: + <<: *mg-express + profiles: + - prod + environment: + ME_CONFIG_BASICAUTH: false + ME_CONFIG_MONGODB_URL: 'mongodb://octopost:1234@db-prod:27017' + db-prod: <<: *db - container_name: octopost-db profiles: - prod From 51cb4fae413481b72603e7ecb753232115986cf7 Mon Sep 17 00:00:00 2001 From: Paulo V T Silva Date: Mon, 26 Aug 2024 14:34:06 -0300 Subject: [PATCH 4/4] chore: remove db url from .env.example --- .env.example | 1 - 1 file changed, 1 deletion(-) diff --git a/.env.example b/.env.example index 24a6ff4..ed82734 100644 --- a/.env.example +++ b/.env.example @@ -8,4 +8,3 @@ MONGO_ROOT_USERNAME="octopost" MONGO_ROOT_PASSWORD="1234" MONGODB_ADMINUSERNAME="octopost" MONGODB_ADMINPASSWORD="1234" -MONGODB_URL="mongodb://octopost:1234@mongo:27017"