Created
January 24, 2020 20:21
-
-
Save pocheptsov/e4fb9d293152ee96d483ff85ef6f46d0 to your computer and use it in GitHub Desktop.
Dockerized Create React App and Proxied Backend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HOST=0.0.0.0 | |
PROXY=http://localhost:3001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DANGEROUSLY_DISABLE_HOST_CHECK=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"extends": "react-app" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const proxy = require('http-proxy-middleware') | |
const target = process.env.PROXY | |
module.exports = app => target && app.use(proxy('/api/', { target })) | |
// app.use((req, res, next) => | |
// req.accepts('text/html') ? next() : proxy({ target })(req, res, next) | |
// ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"compilerOptions": { | |
"baseUrl": "src", | |
"allowJs": true, | |
"allowSyntheticDefaultImports": true, | |
"checkJs": false, | |
"esModuleInterop": true, | |
"forceConsistentCasingInFileNames": true, | |
"isolatedModules": true, | |
"jsx": "preserve", | |
"lib": ["dom", "dom.iterable", "esnext"], | |
"module": "esnext", | |
"moduleResolution": "node", | |
"noEmit": true, | |
"noImplicitAny": false, | |
"resolveJsonModule": true, | |
"skipLibCheck": true, | |
"strict": false, | |
"target": "es5", | |
"typeRoots": ["src/types", "node_modules/@types"] | |
}, | |
"include": ["src"] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.4' | |
services: | |
backend: | |
build: | |
context: . | |
dockerfile: ./docker/Dockerfile | |
args: | |
RUBY_VERSION: '2.6.3' | |
BUNDLER_VERSION: '2.0.2' | |
stdin_open: true | |
tty: true | |
command: bundle exec rails server -b 0.0.0.0 --port 3001 | |
volumes: | |
- .:/app:cached | |
ports: | |
- '3001:3001' | |
tmpfs: | |
- /tmp | |
client: | |
image: node:12.7.0-alpine | |
command: yarn start | |
working_dir: /app | |
ports: | |
- '3000:3000' | |
volumes: | |
- ./client:/app:cached | |
- node_modules:/app/node_modules | |
environment: | |
- NODE_ENV=${NODE_ENV:-development} | |
- CHOKIDAR_USEPOLLING=true | |
depends_on: | |
- backend | |
volumes: | |
node_modules: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment