Skip to content

Instantly share code, notes, and snippets.

@pocheptsov
Created January 24, 2020 20:21
Show Gist options
  • Save pocheptsov/e4fb9d293152ee96d483ff85ef6f46d0 to your computer and use it in GitHub Desktop.
Save pocheptsov/e4fb9d293152ee96d483ff85ef6f46d0 to your computer and use it in GitHub Desktop.
Dockerized Create React App and Proxied Backend
HOST=0.0.0.0
PROXY=http://localhost:3001
DANGEROUSLY_DISABLE_HOST_CHECK=true
{
"extends": "react-app"
}
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)
// )
{
"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"]
}
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