mirror of https://github.com/kern/filepizza
Dockerize FilePizza.
parent
31dd446625
commit
532c996b57
@ -0,0 +1,52 @@
|
|||||||
|
# Logs
|
||||||
|
log
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
|
||||||
|
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directory
|
||||||
|
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
|
||||||
|
node_modules
|
||||||
|
|
||||||
|
# OSX
|
||||||
|
.DS_Store
|
||||||
|
.DS_Store?
|
||||||
|
._*
|
||||||
|
.Spotlight-V100
|
||||||
|
.Trashes
|
||||||
|
ehthumbs.db
|
||||||
|
Thumbs.db
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
Icon
|
||||||
|
|
||||||
|
# Java
|
||||||
|
*.class
|
||||||
|
|
||||||
|
# Git
|
||||||
|
.git
|
||||||
|
|
||||||
|
# FilePizza
|
||||||
|
src
|
||||||
|
resources
|
||||||
|
log
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
FROM node:latest
|
||||||
|
MAINTAINER Alex Kern <alex@pavlovml.com>
|
||||||
|
|
||||||
|
# install
|
||||||
|
RUN mkdir -p /filepizza
|
||||||
|
WORKDIR /filepizza
|
||||||
|
COPY package.json Makefile ./
|
||||||
|
RUN make install
|
||||||
|
COPY . ./
|
||||||
|
|
||||||
|
# run
|
||||||
|
ENV NODE_ENV production
|
||||||
|
EXPOSE 80
|
||||||
|
CMD ./dist/index.js
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
# ==============================================================================
|
||||||
|
# config
|
||||||
|
|
||||||
|
.PHONY: all build clean install push run
|
||||||
|
|
||||||
|
all: run
|
||||||
|
|
||||||
|
WATCH ?= false
|
||||||
|
TAG ?= latest
|
||||||
|
|
||||||
|
# ==============================================================================
|
||||||
|
# phony targets
|
||||||
|
|
||||||
|
build:
|
||||||
|
./node_modules/.bin/babel src --ignore __tests__,__mocks__ --out-dir dist
|
||||||
|
./node_modules/.bin/webpack --optimize-minimize ./src/client
|
||||||
|
docker build -t kern/filepizza:$(TAG) .
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@ rm -rf node_modules
|
||||||
|
@ rm -rf dist
|
||||||
|
|
||||||
|
install:
|
||||||
|
npm install
|
||||||
|
|
||||||
|
push: build
|
||||||
|
docker push kern/filepizza:$(TAG)
|
||||||
|
|
||||||
|
run: | node_modules
|
||||||
|
@ if [ "$(WATCH)" = false ]; then \
|
||||||
|
./node_modules/.bin/babel-node src; \
|
||||||
|
else \
|
||||||
|
./node_modules/.bin/nodemon ./node_modules/.bin/babel-node -i dist src; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ==============================================================================
|
||||||
|
# file targets
|
||||||
|
|
||||||
|
node_modules:
|
||||||
|
npm install
|
||||||
@ -1,10 +0,0 @@
|
|||||||
#! /usr/bin/env node
|
|
||||||
|
|
||||||
try {
|
|
||||||
require('./newrelic')
|
|
||||||
require('newrelic')
|
|
||||||
} catch (ex) {
|
|
||||||
// Don't load New Relic if the configuration file doesn't exist.
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = require('./dist/server')
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
var path = require('path')
|
|
||||||
|
|
||||||
var CLIENT_MODULE_PATH = path.resolve(__dirname, '../client.js')
|
|
||||||
|
|
||||||
module.exports = function (req, res) {
|
|
||||||
res.sendFile(CLIENT_MODULE_PATH)
|
|
||||||
}
|
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
#! /usr/bin/env node
|
||||||
|
|
||||||
|
try {
|
||||||
|
require('../newrelic')
|
||||||
|
require('newrelic')
|
||||||
|
} catch (ex) {
|
||||||
|
// Don't load New Relic if the configuration file doesn't exist.
|
||||||
|
}
|
||||||
|
|
||||||
|
process.on('unhandledRejection', (reason, p) => {
|
||||||
|
p.catch(err => {
|
||||||
|
console.error('Exiting due to unhandled rejection!')
|
||||||
|
console.error(err)
|
||||||
|
process.exit(1)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
process.on('uncaughtException', err => {
|
||||||
|
console.error('Exiting due to uncaught exception!')
|
||||||
|
console.error(err.stack)
|
||||||
|
process.exit(1)
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = require('./server')
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
const path = require('path')
|
||||||
|
|
||||||
|
const BUNDLE_PATH = path.resolve(__dirname, '../../dist/bundle.js')
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV === 'production') {
|
||||||
|
module.exports = function (req, res) {
|
||||||
|
res.sendFile(BUNDLE_PATH)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const webpackMiddleware = require('webpack-dev-middleware')
|
||||||
|
const webpack = require('webpack')
|
||||||
|
const config = require('../../webpack.config.js')
|
||||||
|
config.output.filename = '/js'
|
||||||
|
config.output.path = '/'
|
||||||
|
module.exports = webpackMiddleware(webpack(config))
|
||||||
|
}
|
||||||
@ -1,3 +1,4 @@
|
|||||||
|
import WebTorrent from 'webtorrent'
|
||||||
import socket from 'filepizza-socket'
|
import socket from 'filepizza-socket'
|
||||||
|
|
||||||
export function getClient() {
|
export function getClient() {
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
module.exports = {
|
||||||
|
entry: './src/client',
|
||||||
|
target: 'web',
|
||||||
|
|
||||||
|
output: {
|
||||||
|
filename: 'dist/bundle.js'
|
||||||
|
},
|
||||||
|
|
||||||
|
module: {
|
||||||
|
loaders: [
|
||||||
|
{
|
||||||
|
test: /\.js$/,
|
||||||
|
exclude: /node_modules/,
|
||||||
|
loader: 'babel-loader'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.json$/,
|
||||||
|
loader: 'json'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
node: {
|
||||||
|
fs: 'empty'
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue