Skip to content

Commit

Permalink
feat: proxy server with next config
Browse files Browse the repository at this point in the history
  • Loading branch information
solufa committed Jul 2, 2024
1 parent a2c84de commit 202aaeb
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 520 deletions.
7 changes: 6 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@ COPY server/package.json server/package-lock.json ./server/
RUN npm ci --prefix server

COPY . .

ARG NEXT_PUBLIC_API_BASE_PATH=/api
ARG SERVER_PORT=31577
ENV NEXT_PUBLIC_API_BASE_PATH=$NEXT_PUBLIC_API_BASE_PATH
ENV SERVER_PORT=$SERVER_PORT

ARG NEXT_PUBLIC_COGNITO_POOL_ENDPOINT
ARG COGNITO_ACCESS_KEY
ARG COGNITO_SECRET_KEY
ARG COGNITO_REGION
ARG COGNITO_USER_POOL_ID
ARG COGNITO_USER_POOL_CLIENT_ID
ARG DATABASE_URL
ENV NEXT_PUBLIC_API_BASE_PATH=$NEXT_PUBLIC_API_BASE_PATH

RUN npm run build

HEALTHCHECK --interval=5s --timeout=5s --retries=3 CMD curl -f http://localhost:$PORT/$NEXT_PUBLIC_API_BASE_PATH/health && curl -f http://localhost:$PORT || exit 1
Expand Down
1 change: 1 addition & 0 deletions client/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
NEXT_PUBLIC_API_BASE_PATH=/api
NEXT_PUBLIC_COGNITO_POOL_ENDPOINT=http://localhost:5050
NEXT_PUBLIC_GA_ID=
SERVER_PORT=31577
COGNITO_USER_POOL_ID=ap-northeast-1_frourio
COGNITO_USER_POOL_CLIENT_ID=next-frourio-starter
16 changes: 6 additions & 10 deletions client/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,10 @@ module.exports = {

return config;
},
...(process.env.NODE_ENV === 'development'
? {
rewrites: async () => [
{
source: `${process.env.NEXT_PUBLIC_API_BASE_PATH}/:path*`,
destination: `http://localhost:31577${process.env.NEXT_PUBLIC_API_BASE_PATH}/:path*`,
},
],
}
: { output: 'export' }),
rewrites: async () => [
{
source: `${process.env.NEXT_PUBLIC_API_BASE_PATH}/:path*`,
destination: `http://localhost:${process.env.SERVER_PORT}${process.env.NEXT_PUBLIC_API_BASE_PATH}/:path*`,
},
],
};
1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"dev:aspida": "aspida --watch",
"dev:path": "pathpida --ignorePath .gitignore -s -w",
"build": "npm run generate && next build",
"start": "next start",
"lint": "run-p lint:js lint:prettier lint:style",
"lint:js": "eslint --ext .ts,.tsx,.js --ignore-path .gitignore .",
"lint:prettier": "prettier --check \"./**/*.{ts,tsx,js}\" --ignore-path .gitignore",
Expand Down
2 changes: 1 addition & 1 deletion compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
magnito:
image: frourio/magnito:0.10.0
image: frourio/magnito:0.10.1
ports:
- 5050:5050
- 5051:5051
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
"lint": "run-p lint:*",
"lint:client": "npm run lint:fix --prefix client",
"lint:server": "npm run lint:fix --prefix server",
"start": "npm start --prefix server",
"start": "run-p start:*",
"start:client": "npm start --prefix client",
"start:server": "npm start --prefix server",
"test": "run-p test:*",
"test:client": "npm run test --prefix client",
"test:server": "npm run test --prefix server",
Expand Down
1 change: 0 additions & 1 deletion server/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
PORT=31577
COGNITO_ACCESS_KEY=cognito-access-key
COGNITO_SECRET_KEY=cognito-secret-key
COGNITO_REGION=ap-northeast-1
Expand Down
4 changes: 2 additions & 2 deletions server/entrypoints/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { init } from 'service/app';
import { PORT } from 'service/envValues';
import { SERVER_PORT } from 'service/envValues';

init().listen({ port: PORT, host: '0.0.0.0' });
init().listen({ port: SERVER_PORT, host: '0.0.0.0' });
Loading

0 comments on commit 202aaeb

Please sign in to comment.