Add static assets to nginx
This commit is contained in:
+2
-2
@@ -10,8 +10,8 @@
|
|||||||
"build": "nest build",
|
"build": "nest build",
|
||||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||||
"start": "nest start",
|
"start": "nest start",
|
||||||
"start:dev": "nest start --watch",
|
"start:dev": "nest start --watch --preserveWatchOutput",
|
||||||
"start:debug": "nest start --debug --watch",
|
"start:debug": "nest start --debug --watch --preserveWatchOutput",
|
||||||
"start:prod": "node dist/main",
|
"start:prod": "node dist/main",
|
||||||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
|
|||||||
+18
-1
@@ -40,13 +40,14 @@ services:
|
|||||||
retries: 5
|
retries: 5
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "5432:5432"
|
||||||
|
|
||||||
front:
|
front:
|
||||||
build:
|
build:
|
||||||
context: ./front
|
context: ./front
|
||||||
dockerfile: Dockerfile.dev
|
dockerfile: Dockerfile.dev
|
||||||
environment:
|
environment:
|
||||||
- SCOROMETER_URL=http://scorometer:6543/
|
- SCOROMETER_URL=http://scorometer:6543/
|
||||||
- NGINX_PORT=80
|
- NGINX_PORT=4567
|
||||||
ports:
|
ports:
|
||||||
- "19006:19006"
|
- "19006:19006"
|
||||||
volumes:
|
volumes:
|
||||||
@@ -55,3 +56,19 @@ services:
|
|||||||
- "back"
|
- "back"
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
|
|
||||||
|
nginx:
|
||||||
|
image: nginx
|
||||||
|
environment:
|
||||||
|
- API_URL=http://back:3000
|
||||||
|
- SCOROMETER_URL=http://scorometer:6543
|
||||||
|
- FRONT_URL=http://front:19006
|
||||||
|
- PORT=4567
|
||||||
|
depends_on:
|
||||||
|
- back
|
||||||
|
- front
|
||||||
|
volumes:
|
||||||
|
- "./front/assets:/assets:ro"
|
||||||
|
- "./front/nginx.conf.template.dev:/etc/nginx/templates/default.conf.template:ro"
|
||||||
|
ports:
|
||||||
|
- "4567:4567"
|
||||||
|
|||||||
+1
-5
@@ -35,11 +35,7 @@ services:
|
|||||||
retries: 5
|
retries: 5
|
||||||
|
|
||||||
front:
|
front:
|
||||||
build:
|
build: ./front
|
||||||
context: ./front
|
|
||||||
args:
|
|
||||||
- API_URL=${API_URL}
|
|
||||||
- SCORO_URL=${SCORO_URL}
|
|
||||||
environment:
|
environment:
|
||||||
- API_URL=http://back:3000/
|
- API_URL=http://back:3000/
|
||||||
- SCOROMETER_URL=http://scorometer:6543/
|
- SCOROMETER_URL=http://scorometer:6543/
|
||||||
|
|||||||
+3
-2
@@ -22,6 +22,7 @@ RUN yarn tsc && expo build:web
|
|||||||
# Serve the app
|
# Serve the app
|
||||||
FROM nginx:1.21-alpine
|
FROM nginx:1.21-alpine
|
||||||
COPY --from=build /app/web-build /usr/share/nginx/html
|
COPY --from=build /app/web-build /usr/share/nginx/html
|
||||||
COPY nginx.conf.template /etc/nginx/conf.d/default.conf.template
|
COPY ./assets/ /usr/share/nginx/html/assets/
|
||||||
|
COPY nginx.conf.template /etc/nginx/templates/default.conf.template
|
||||||
|
|
||||||
CMD envsubst '$API_URL $SCOROMETER_URL $NGINX_PORT' < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'
|
CMD nginx -g 'daemon off;'
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,13 @@
|
|||||||
|
import { useEffect, useRef } from 'react';
|
||||||
|
|
||||||
|
export const Metronome = ({ paused = false, bpm }: { paused?: boolean; bpm: number }) => {
|
||||||
|
const ref = useRef<HTMLAudioElement | null>(null);
|
||||||
|
useEffect(() => {
|
||||||
|
const int = setInterval(() => {
|
||||||
|
if (!ref.current) ref.current = new Audio("/assets/metronome.mp3");
|
||||||
|
ref.current.play();
|
||||||
|
}, 60000 / bpm);
|
||||||
|
return () => clearInterval(int);
|
||||||
|
}, []);
|
||||||
|
return null;
|
||||||
|
};
|
||||||
@@ -4,6 +4,10 @@ server {
|
|||||||
|
|
||||||
index index.html;
|
index index.html;
|
||||||
|
|
||||||
|
location /assets {
|
||||||
|
alias ./assets;
|
||||||
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
try_files $uri $uri/ /index.html;
|
try_files $uri $uri/ /index.html;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
server {
|
||||||
|
listen ${PORT};
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
location /assets {
|
||||||
|
alias /assets;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass ${FRONT_URL}/;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /api/ {
|
||||||
|
proxy_pass ${API_URL}/;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /ws {
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-Scheme $scheme;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_set_header X-Forwarded-For $remote_addr;
|
||||||
|
proxy_pass ${SCOROMETER_URL};
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection $http_connection;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,6 +33,7 @@ import { MIDIAccess, MIDIMessageEvent, requestMIDIAccess } from '@motiz88/react-
|
|||||||
import * as Linking from 'expo-linking';
|
import * as Linking from 'expo-linking';
|
||||||
import url from 'url';
|
import url from 'url';
|
||||||
import { PianoCanvasContext, PianoCanvasMsg, NoteTiming } from '../models/PianoGame';
|
import { PianoCanvasContext, PianoCanvasMsg, NoteTiming } from '../models/PianoGame';
|
||||||
|
import { Metronome } from '../components/Metronome';
|
||||||
|
|
||||||
type PlayViewProps = {
|
type PlayViewProps = {
|
||||||
songId: number;
|
songId: number;
|
||||||
@@ -357,6 +358,8 @@ const PlayView = ({ songId, type, route }: RouteProps<PlayViewProps>) => {
|
|||||||
{!partitionRendered && <LoadingComponent />}
|
{!partitionRendered && <LoadingComponent />}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
<Metronome paused={paused} bpm={60} />
|
||||||
|
|
||||||
<Box
|
<Box
|
||||||
shadow={4}
|
shadow={4}
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
Reference in New Issue
Block a user