From 13f974371d59df0375a47cff81461f29e5b6ef16 Mon Sep 17 00:00:00 2001 From: sammrai <13623491+sammrai@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:55:59 +0900 Subject: [PATCH 1/2] Fix CORS issue for local development --- Dockerfile | 15 +++++++++++++++ docker-compose.yml | 18 ++++++++++++++++++ nginx.conf | 22 ++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3c2fed2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM node:18 + +WORKDIR /app + +COPY package*.json ./ + +RUN npm install + +COPY . . + +RUN npm run build + +EXPOSE 3000 + +CMD ["npm", "start"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..78df601 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +version: '3' +services: + hyperliquid-stats-web: + build: . + volumes: + - .:/app + - /app/node_modules + command: npm run dev + environment: + NEXT_PUBLIC_API_URL: /api + PORT: 80 + + web: + image: nginx:alpine + ports: + - "3002:80" + volumes: + - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..877a6ce --- /dev/null +++ b/nginx.conf @@ -0,0 +1,22 @@ +server { + listen 80; + + location /api/ { + proxy_pass https://stats-api.hyperliquid.xyz/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_ssl_session_reuse off; + proxy_ssl_verify off; + } + location / { + proxy_pass http://hyperliquid-stats-web; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_ssl_session_reuse off; + proxy_ssl_verify off; + } +} From e71c52be4d91043dafffdba34d04ca9f61c630da Mon Sep 17 00:00:00 2001 From: sammrai <13623491+sammrai@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:59:56 +0900 Subject: [PATCH 2/2] Fix README.md --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index 9020599..c4027a2 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,30 @@ You can start editing the page by modifying `app/page.tsx`. The page auto-update This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. +## Using Docker Compose for Development + +To simplify the setup and ensure consistency across different development environments, you can use Docker Compose to run the project. This method requires Docker and Docker Compose to be installed on your machine. + +1. Build the Docker images: + +```bash +docker-compose build +``` + +2. Start the services: + +```bash +docker-compose up -d +``` + +This will start the Next.js development server and any other services defined in your `docker-compose.yml`, such as Nginx or a database, making them accessible via `http://localhost:3002` or another port specified in your Docker Compose configuration. + +To stop the services, use: + +```bash +docker-compose down +``` + ## Learn More To learn more about Next.js, take a look at the following resources: