Add basic docker support for development

Assuming docker engine is installed, it is now possible to run the dev
server using 'docker-compose up --build' or run the production version using
'docker build -t bitburner . && docker run -it -p 8000:80 bitburner'.
This commit is contained in:
Martin Fournier
2021-05-08 15:02:26 -04:00
parent 2bd4892fa8
commit ac8565d820
5 changed files with 84 additions and 5 deletions

View File

@@ -5,6 +5,7 @@ var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = (env, argv) => {
const isDevServer = (env || {}).devServer === true;
const runInContainer = (env || {}).runInContainer === true;
const isDevelopment = argv.mode === 'development';
const outputDirectory = isDevServer ? "dist-dev" : "dist";
const entries = {};
@@ -22,6 +23,22 @@ module.exports = (env, argv) => {
entrypoints: true,
}
const devServerSettings = {
port: 8000,
publicPath: `/`,
stats: statsConfig,
};
// By default, the webpack-dev-server is not exposed outside of localhost.
// When running in a container we need it accessible externally.
if (runInContainer) {
devServerSettings.disableHostCheck = true;
devServerSettings.host = '0.0.0.0';
devServerSettings.watchOptions = {
poll: true,
}
}
return {
plugins: [
new webpack.DefinePlugin({
@@ -131,11 +148,7 @@ module.exports = (env, argv) => {
},
},
},
devServer: {
port: 8000,
publicPath: `/`,
stats: statsConfig,
},
devServer: devServerSettings,
resolve: {
extensions: [
".tsx",