-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b1b334b
commit c08e161
Showing
3 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Dockerfile | ||
dist/ | ||
prisma/generated/ | ||
prismaDmob/generated/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Build docker image | ||
on: | ||
pull_request: | ||
types: [opened, synchronize] | ||
push: | ||
branches: | ||
- develop | ||
- docker | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
services: | ||
postgres: | ||
image: postgres | ||
env: | ||
POSTGRES_PASSWORD: postgres | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
- 5432:5432 | ||
postgresDmob: | ||
image: postgres | ||
env: | ||
POSTGRES_PASSWORD: postgres | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
- 5433:5432 | ||
env: | ||
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres | ||
DMOB_DATABASE_URL: postgres://postgres:postgres@localhost:5433/postgres | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Install prisma | ||
run: npm install prisma@latest | ||
|
||
- name: Init tmp db | ||
run: npx prisma migrate reset --force --schema=./prisma/schema.prisma | ||
|
||
- name: Init dmob-like tmp db | ||
run: npx prisma migrate reset --force --schema=./prismaDmob/schema.prisma | ||
|
||
- name: Build | ||
env: | ||
DATABASE_URL: postgres://postgres:[email protected]:5432/postgres | ||
DMOB_DATABASE_URL: postgres://postgres:[email protected]:5433/postgres | ||
run: docker build --secret id=DATABASE_URL --secret id=DMOB_DATABASE_URL . --add-host=host.docker.internal:host-gateway | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
FROM node:20-alpine AS builder | ||
USER node | ||
WORKDIR /app | ||
COPY package*.json ./ | ||
RUN npm ci | ||
COPY --chown=1000:1000 . . | ||
RUN --mount=type=secret,id=DATABASE_URL,uid=1000 \ | ||
env DATABASE_URL=$(cat /run/secrets/DATABASE_URL) \ | ||
npx prisma generate --sql --schema=./prisma/schema.prisma | ||
|
||
RUN --mount=type=secret,id=DMOB_DATABASE_URL,uid=1000 \ | ||
env DMOB_DATABASE_URL=$(cat /run/secrets/DMOB_DATABASE_URL) \ | ||
npx prisma generate --sql --schema=./prismaDmob/schema.prisma | ||
|
||
RUN npm run build | ||
|
||
FROM node:20-alpine AS runner | ||
ENV NODE_ENV=production | ||
USER node | ||
WORKDIR /app | ||
COPY --from=builder --chown=node:node /app/package*.json ./ | ||
COPY --from=builder --chown=node:node /app/node_modules/ ./node_modules/ | ||
COPY --from=builder --chown=node:node /app/dist/ ./dist/ | ||
COPY --from=builder --chown=node:node /app/prisma/ ./prisma/ | ||
COPY --from=builder --chown=node:node /app/prismaDmob/ ./prismaDmob/ | ||
CMD [ "node", "dist/main.js" ] |