Last active
May 23, 2021 05:35
-
-
Save MollsReis/fd2b44997765f31f2c0e0b967f5930a4 to your computer and use it in GitHub Desktop.
Preact docker-compose boilerplate
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
Show hidden characters
{ | |
"presets": ["env", "stage-2"], | |
"plugins": [ | |
["transform-react-jsx", { "pragma": "h" }] | |
] | |
} |
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.3' | |
services: | |
server: | |
image: 'projectname-prod-server:latest' | |
build: | |
context: '.' | |
dockerfile: 'Dockerfile.prod' | |
depends_on: | |
- 'redis' | |
restart: 'always' | |
working_dir: '/app' | |
entrypoint: 'yarn run prod-server' | |
redis: | |
image: 'redis:4-alpine' | |
restart: 'always' | |
nginx: | |
image: 'projectname-nginx:latest' | |
build: | |
context: '.' | |
dockerfile: 'Dockerfile.nginx' | |
depends_on: | |
- 'server' | |
ports: | |
- '80:8080' | |
restart: 'always' |
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.3' | |
services: | |
deps: | |
image: 'projectname-deps:latest' | |
build: | |
context: '.' | |
dockerfile: 'Dockerfile.deps' | |
volumes: | |
- 'node_modules:/node_modules' | |
watch: | |
image: 'node:9-alpine' | |
depends_on: | |
- 'deps' | |
environment: | |
- 'PATH=$PATH:/root/.node_modules/.bin/' | |
restart: 'always' | |
volumes: | |
- '.:/app' | |
- 'node_modules:/root/.node_modules' | |
working_dir: '/app' | |
entrypoint: 'yarn run watch' | |
server: | |
image: 'node:9-alpine' | |
depends_on: | |
- 'deps' | |
- 'redis' | |
environment: | |
- 'PATH=$PATH:/root/.node_modules/.bin/' | |
restart: 'always' | |
volumes: | |
- '.:/app' | |
- 'node_modules:/root/.node_modules' | |
working_dir: '/app' | |
entrypoint: 'yarn run server' | |
redis: | |
image: 'redis:4-alpine' | |
restart: 'always' | |
nginx: | |
image: 'projectname-nginx:latest' | |
build: | |
context: '.' | |
dockerfile: 'Dockerfile.nginx' | |
depends_on: | |
- 'server' | |
ports: | |
- '8080:8080' | |
restart: 'always' | |
volumes: | |
node_modules: |
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
FROM node:9-alpine | |
ADD package.json . | |
ADD yarn.lock . | |
RUN yarn install | |
CMD echo "ready" |
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
FROM nginx:1.15-alpine | |
COPY nginx.conf /etc/nginx/nginx.conf |
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
FROM node:9-alpine | |
WORKDIR /app | |
ADD src src | |
ADD package.json . | |
ADD yarn.lock . | |
RUN yarn install | |
ENV NODE_ENV=production | |
ADD .babelrc . | |
ADD webpack.config.js . | |
RUN yarn run build |
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
events { | |
worker_connections 1024; | |
} | |
http { | |
upstream node { | |
server server:8080; | |
} | |
server { | |
listen 8080; | |
server_tokens off; | |
location / { | |
proxy_pass http://node; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection 'upgrade'; | |
proxy_set_header Host $host; | |
proxy_cache_bypass $http_upgrade; | |
} | |
} | |
} |
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
{ | |
"devDependencies": { | |
"babel-core": "6", | |
"babel-loader": "^7.1.4", | |
"babel-plugin-transform-react-jsx": "^6.24.1", | |
"babel-polyfill": "^6.26.0", | |
"babel-preset-env": "^1.7.0", | |
"babel-preset-stage-2": "^6.24.1", | |
"css-loader": "^0.28.11", | |
"less": "^3.0.4", | |
"less-loader": "^4.1.0", | |
"nodemon": "^1.17.5", | |
"style-loader": "^0.21.0", | |
"webpack": "^4.9.2", | |
"webpack-command": "^0.2.0" | |
}, | |
"scripts": { | |
"watch": "webpack --mode development --watch --watch-poll 1000", | |
"server": "nodemon --watch src/lib src/lib/server.js", | |
"build": "webpack --mode production", | |
"prod-server": "node src/lib/server.js" | |
} | |
} |
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 os = require('os'), | |
path = require('path'), | |
webpack = require('webpack'); | |
const APP_DIR = path.resolve(__dirname, 'src/app'), | |
BUILD_DIR = path.resolve(__dirname, 'src/public'); | |
module.exports = { | |
entry: ['babel-polyfill', APP_DIR + '/index.js'], | |
module: { | |
rules: [ | |
{ | |
include: APP_DIR, | |
loader: 'babel-loader', | |
test: /\.js/ | |
}, | |
{ | |
test: /\.less$/, | |
include: [ | |
path.resolve(os.homedir(), '.node_modules'), | |
APP_DIR + '/styles' | |
], | |
loaders: ['style-loader', 'css-loader', 'less-loader'], | |
} | |
] | |
}, | |
output: { | |
filename: 'bundle.js', | |
path: BUILD_DIR | |
}, | |
resolveLoader: { | |
modules: [ | |
path.resolve(os.homedir(), '.node_modules'), | |
'node_modules' | |
] | |
}, | |
resolve: { | |
modules: [ | |
path.resolve(os.homedir(), '.node_modules'), | |
'node_modules' | |
] | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment