diff --git a/app/package.json b/app/package.json index 17996a61..ef135f5b 100644 --- a/app/package.json +++ b/app/package.json @@ -1,5 +1,5 @@ { - "name": "app", + "name": "wrolpi-app", "version": "0.1.0", "private": true, "dependencies": { @@ -12,7 +12,7 @@ "react-router-dom": "^5.2.0", "react-scripts": "^3.4.1", "react-semantic-toasts": "^0.6.5", - "react-timezone-select": "^1.0.5", + "react-timezone-select": "0.8.4", "semantic-ui-offline": "^2.4.1-1", "semantic-ui-react": "^0.88.2", "yargs-parser": "^18.1.2" diff --git a/docker-compose.yml b/docker-compose.yml index 1834ea55..a2263a4d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,6 +8,7 @@ services: - POSTGRES_PASSWORD=wrolpi ports: - '54321:5432' + - '5432:5432' healthcheck: test: [ 'CMD-SHELL', 'pg_isready -U postgres' ] @@ -47,11 +48,11 @@ services: build: context: . dockerfile: docker/app/Dockerfile - ports: - - '8082:8082' volumes: - - './app:/app' - command: 'yarn start' + - './app/public:/app/public' + - './app/src:/app/src' + - './app/package.json:/app/package.json' + command: 'npm run start' stdin_open: true healthcheck: test: [ 'CMD-SHELL', 'curl http://127.0.0.1:3000' ] @@ -64,7 +65,7 @@ services: ports: - ${WEB_HOST-0.0.0.0}:${WEB_PORT-8080}:80 volumes: - - './nginx.conf:/etc/nginx/nginx.conf' + - './nginx.dev.conf:/etc/nginx/nginx.conf' - './icon.ico:/etc/nginx/favicon.ico' - './icon.png:/etc/nginx/icon.png' - './test:/opt/media' diff --git a/docker/app/Dockerfile b/docker/app/Dockerfile index 94266af1..4d77aef4 100644 --- a/docker/app/Dockerfile +++ b/docker/app/Dockerfile @@ -10,10 +10,9 @@ COPY app/src /app/src COPY app/package.json /app/ RUN rm -rf /app/node_modules # Increase network timeout because a Raspberry Pi is slow. -RUN yarn --silent --network-timeout 100000 +RUN yarn --network-timeout 100000 # Create the production build -RUN yarn run build RUN yarn global add serve # Run the production build diff --git a/nginx.conf b/nginx.conf index 9482d322..d2752e1f 100644 --- a/nginx.conf +++ b/nginx.conf @@ -19,19 +19,19 @@ http { location / { # React APP - proxy_pass http://app:3000; + proxy_pass http://127.0.0.1:5000; rewrite $1 break; } location /sockjs-node { - proxy_pass http://app:3000; + proxy_pass http://127.0.0.1:5000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } location /api { - proxy_pass http://api:8081; + proxy_pass http://127.0.0.1:8081; rewrite /^api(.*)$ $1 break; } diff --git a/nginx.dev.conf b/nginx.dev.conf new file mode 100644 index 00000000..9482d322 --- /dev/null +++ b/nginx.dev.conf @@ -0,0 +1,53 @@ +events { + +} + +http { + map $http_upgrade $connection_upgrade { + default upgrade; + '' close; + } + + server { + location /favicon.ico { + alias /etc/nginx/favicon.ico; + } + + location /apple-touch-icon.png { + alias /etc/nginx/icon.png; + } + + location / { + # React APP + proxy_pass http://app:3000; + rewrite $1 break; + } + + location /sockjs-node { + proxy_pass http://app:3000; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + } + + location /api { + proxy_pass http://api:8081; + rewrite /^api(.*)$ $1 break; + } + + location /media { + # The media files mounted in the docker volume + sendfile on; + sendfile_max_chunk 1m; + + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + + autoindex on; + autoindex_exact_size off; + alias /opt/media; + } + } + +}