Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ajust compose and env.example #173

Merged
merged 4 commits into from
Aug 27, 2024
Merged
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
9 changes: 4 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ 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"
21 changes: 0 additions & 21 deletions .github/workflows/auto-assign.yml

This file was deleted.

11 changes: 11 additions & 0 deletions .github/workflows/base-workflows.yml
Original file line number Diff line number Diff line change
@@ -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
28 changes: 21 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
CMD ["pnpm", "start"]
35 changes: 20 additions & 15 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
services:
db-dev: &db
container_name: octopost-db-dev
profiles:
- dev
image: mongo:latest
image: mongo:7.0.14-rc0-jammy
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:

mongo-express-dev: &mg-express
profiles:
- dev
image: mongo-express
depends_on: [db-dev]
ports:
- 8081: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://octopost:1234@db-dev:27017'
ME_CONFIG_BASICAUTH: false
links:
- db-dev
networks:
- octopost

api:
build:
context: ./
Expand All @@ -37,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

Expand Down
Loading