Skip to content

Commit

Permalink
Integrate Dockerfile in app
Browse files Browse the repository at this point in the history
  • Loading branch information
bperel committed Nov 20, 2023
1 parent 8219c22 commit 32912b5
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 102 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deploy-ducksmanager.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
uses: docker/build-push-action@v3
with:
context: .
file: apps/web/Dockerfile
platforms: linux/x86_64
push: true
target: web
Expand All @@ -67,6 +68,7 @@ jobs:
uses: docker/build-push-action@v3
with:
context: .
file: apps/web/Dockerfile
platforms: linux/x86_64
push: true
target: api
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/deploy-dumili.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
push:
paths:
- ".github/workflows/deploy-dumili.yml"
- "apps/dumili/**"
- "apps/dumili"
- "pnpm-lock.yaml"
branches:
- "master"
Expand Down Expand Up @@ -58,6 +58,7 @@ jobs:
uses: docker/build-push-action@v3
with:
context: .
file: apps/dumili/Dockerfile
platforms: linux/x86_64
push: true
target: dumili
Expand All @@ -70,6 +71,7 @@ jobs:
uses: docker/build-push-action@v3
with:
context: .
file: apps/dumili/Dockerfile
platforms: linux/x86_64
push: true
target: dumili-api
Expand All @@ -82,6 +84,7 @@ jobs:
uses: docker/build-push-action@v3
with:
context: apps/dumili/kumiko
file: apps/dumili/kumiko/Dockerfile
platforms: linux/x86_64
push: true
cache-from: type=registry,ref=ghcr.io/bperel/kumiko:buildcache
Expand All @@ -93,6 +96,7 @@ jobs:
uses: docker/build-push-action@v3
with:
context: apps/dumili/paddleocr
file: apps/dumili/paddleocr/Dockerfile
platforms: linux/x86_64
push: true
cache-from: type=registry,ref=ghcr.io/bperel/paddleocr:buildcache
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
dist
dist-ssr
node_modules
.eslintcache
**/.eslintcache
95 changes: 0 additions & 95 deletions Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion apps/dumili
48 changes: 48 additions & 0 deletions apps/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
FROM node:18 as pnpm

ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

FROM pnpm AS build

WORKDIR /app
COPY . ./
RUN --mount=type=cache,id=pnpm-store,target=/app/.pnpm-store \
pnpm -r -F ~web... -F ~api... i

RUN pnpm -r -F ~web... -F ~api... run build

FROM nginx AS web
LABEL org.opencontainers.image.authors="Bruno Perel"

COPY apps/web/nginx.conf /etc/nginx/nginx.conf
COPY --from=build /app/apps/web/dist /usr/share/nginx/html


FROM pnpm AS api
LABEL org.opencontainers.image.authors="Bruno Perel"

WORKDIR /app

COPY {package.json,pnpm-*.yaml}.yaml ./
COPY --from=build /app/packages/prisma-clients ./packages/prisma-clients
COPY --from=build /app/packages/types ./packages/types
COPY --from=build /app/packages/prisma-clients/dist/ ./packages/prisma-clients
COPY --from=build /app/packages/types/dist/ ./packages/types

WORKDIR /app/packages/api
COPY --from=build /app/packages/api/dist/api ./

COPY packages/api/{package.json,translations} ./

RUN --mount=type=cache,id=pnpm-store,target=/app/.pnpm-store \
pnpm i --production

COPY ./packages/api/routes/demo/*.csv ./routes/demo/
COPY ./packages/api/emails ./emails/
COPY ./packages/api/.env ./.env

EXPOSE 3000

CMD ["node", "index.js"]
4 changes: 3 additions & 1 deletion packages/api-routes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@
"node": ">=18.0.0 <19.0.0"
},
"scripts": {
"dev": "pnpm run build",
"dev": "pnpm build",
"build": "tsx generate-route-types.ts && eslint -c .eslintrc.js --fix index.ts && rm -rf dist && ./node_modules/.bin/tsc"
},
"dependencies": {
"axios": "^1.5.1",
"express": "^4.18.2",
"express-file-routing": "^3.0.3",
"jsonwebtoken": "^9.0.2",
"tsx": "^3.14.0",
"~axios-helper": "workspace:*",
"~dm-types": "workspace:*",
"~prisma-clients": "workspace:*"
},
"devDependencies": {
"@types/express": "^4.17.20",
"@types/jsonwebtoken": "^9.0.4",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"eslint": "^8.52.0",
"eslint-config-prettier": "^9.0.0",
Expand Down
84 changes: 81 additions & 3 deletions packages/api-routes/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 32912b5

Please sign in to comment.