Skip to content

Commit

Permalink
feat: proxy client with server cli
Browse files Browse the repository at this point in the history
  • Loading branch information
solufa committed Sep 11, 2024
1 parent f7b7da7 commit 6d827a3
Show file tree
Hide file tree
Showing 13 changed files with 1,105 additions and 675 deletions.
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ FROM node:20-alpine
WORKDIR /usr/src/app

ARG CLIENT_PORT=5051
ARG SSL_PORT=5052

ENV PORT=5050
ENV CLIENT_PORT=$CLIENT_PORT
ENV SSL_PORT=$SSL_PORT
ENV COGNITO_ACCESS_KEY=magnito-access-key
ENV COGNITO_SECRET_KEY=magnito-secret-key
ENV COGNITO_REGION=ap-northeast-1
Expand All @@ -44,14 +46,15 @@ COPY --chown=node package.json ./
COPY --chown=node server/package.json server/package-lock.json ./server/

COPY --chown=node --from=builder /usr/src/app/client/out client/out/
COPY --chown=node --from=builder /usr/src/app/server/certificates server/certificates/
COPY --chown=node --from=builder /usr/src/app/server/node_modules server/node_modules/
COPY --chown=node --from=builder /usr/src/app/server/index.js server/index.js
COPY --chown=node --from=builder /usr/src/app/server/prisma server/prisma/
COPY --chown=node --from=builder /usr/src/app/data data/

HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD wget --quiet --spider http://127.0.0.1:$PORT/public/health && wget --quiet --spider http://127.0.0.1:$CLIENT_PORT || exit 1
HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD wget --quiet --spider http://127.0.0.1:$PORT/public/health && wget --quiet --spider http://127.0.0.1:$CLIENT_PORT && wget --quiet --spider https://127.0.0.1:$SSL_PORT || exit 1

EXPOSE ${PORT} ${CLIENT_PORT}
EXPOSE ${PORT} ${CLIENT_PORT} ${SSL_PORT}
VOLUME ["/usr/src/app/data"]

USER node
Expand Down
1 change: 0 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"scripts": {
"dev": "run-p dev:*",
"dev:client": "next dev -p 5051",
"dev:ssl": "local-ssl-proxy --key ./certificates/server.key --cert ./certificates/server.crt --source 5052 --target 5051",
"dev:hcm": "hcm '**/*.module.css' -w",
"dev:aspida": "aspida --watch",
"dev:path": "pathpida --ignorePath ../.gitignore -s -w",
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build": "run-p build:*",
"build:client": "npm run build --prefix client",
"build:server": "npm run build --prefix server",
"start": "npm run start --prefix server",
"start": "npm start --prefix server",
"generate": "run-p generate:*",
"generate:client": "npm run generate --prefix client",
"generate:server": "npm run generate --prefix server",
Expand All @@ -23,8 +23,8 @@
"lint:server": "npm run lint --prefix server",
"fix:lint": "npm run lint:js -- --fix && npm run lint:style -- --fix && npm run lint:prettier -- --write",
"test": "run-p test:*",
"test:client": "npm run test --prefix client",
"test:server": "npm run test --prefix server",
"test:client": "npm test --prefix client",
"test:server": "npm test --prefix server",
"typecheck": "run-p typecheck:*",
"typecheck:client": "npm run typecheck --prefix client",
"typecheck:server": "npm run typecheck --prefix server"
Expand Down
1 change: 1 addition & 0 deletions server/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
PORT=5050
CLIENT_PORT=
SSL_PORT=
DATABASE_URL=file:../../data/app.db
TEST_DATABASE_URL=file:../../data/test.db
SMTP_HOST=localhost
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 2 additions & 4 deletions server/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { userPoolUseCase } from 'domain/userPool/useCase/userPoolUseCase';
import { init, serveClient } from 'service/app';
import { CLIENT_PORT, PORT } from 'service/envValues';
import { init } from 'service/app';
import { PORT } from 'service/envValues';

userPoolUseCase.initDefaults().then(() => init().listen({ port: PORT, host: '0.0.0.0' }));

if (CLIENT_PORT) serveClient().listen({ port: CLIENT_PORT, host: '0.0.0.0' });
Loading

0 comments on commit 6d827a3

Please sign in to comment.