Skip to content

Commit

Permalink
Update docker files for open source
Browse files Browse the repository at this point in the history
  • Loading branch information
vicmgs committed Feb 25, 2021
1 parent 642223f commit 019d331
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 8 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ ENV MIX_ENV=prod
COPY mix.lock mix.lock
COPY mix.exs mix.exs
COPY config config
RUN rm config/prod.exs
RUN mv config/prod-docker.exs config/prod.exs
RUN mix deps.get --only $MIX_ENV
RUN mix deps.compile

# build assets
COPY assets assets
RUN rm assets/webpack.config.js
RUN mv assets/webpack-docker.config.js assets/webpack.config.js
RUN cd assets && yarn && yarn run deploy
RUN mix phx.digest

Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.
## Running with Docker

* Clone the repo and `cd console`
* Follow instructions at the top of `/config/prod.exs`
* Follow instructions at the bottom of `/assets/webpack.config.js`
* Update host at the top of `/config/releases.exs`
* Sign up with Auth0 (https://auth0.com/)
* Create .env file in root folder
* Create .env and .env-router files in root folder
* Populate .env file with the following

```
Expand Down
53 changes: 53 additions & 0 deletions assets/webpack-docker.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const path = require('path');
const webpack = require('webpack')
const dotenv = require('dotenv').config( {
path: path.join(__dirname, '.env')
} );

module.exports = function(env) {
const production = process.env.NODE_ENV === 'production';
return {
devtool: production ? 'source-maps' : 'eval',
entry: './js/app.js',
output: {
path: path.resolve(__dirname, '../priv/static/js'),
filename: 'app.js',
publicPath: '/',
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
{
test: /\.css$/,
use: [ 'style-loader', 'css-loader' ]
},
{
test: /\.(png|svg|jpg|gif)$/,
use: [
{
loader: 'file-loader',
options: {
publicPath: '/js'
}
}
]
},
],
},
resolve: {
modules: ['node_modules', path.resolve(__dirname, 'js')],
extensions: ['.js', '.jsx'],
},
plugins: [
new webpack.DefinePlugin({
'process.env.SELF_HOSTED': true
})
],
};
};
4 changes: 0 additions & 4 deletions assets/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ module.exports = function(env) {
},
plugins: [
new webpack.EnvironmentPlugin(['AUTH_0_DOMAIN', 'AUTH_0_CLIENT_ID', 'ENV_DOMAIN', 'STRIPE_PUBLIC_KEY', 'SELF_HOSTED', 'INTERCOM_ID_SECRET', 'CONSOLE_VERSION', 'RELEASE_BLOG_LINK'])
// new webpack.DefinePlugin({
// 'process.env.SELF_HOSTED': true,
// 'process.env.ENV_DOMAIN': "localhost",
// }) // UNCOMMENT FOR OPEN SOURCE RUNNING AND COMMENT OUT ABOVE LINE
],
};
};
1 change: 1 addition & 0 deletions config/prod-docker.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use Mix.Config
1 change: 0 additions & 1 deletion config/prod.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use Mix.Config

# COMMENT OUT EVERYTHING BELOW FOR OPEN SOURCE
config :console, ConsoleWeb.Endpoint,
load_from_system_env: true,
url: [scheme: "https", host: System.get_env("HOSTNAME"), port: 443],
Expand Down

0 comments on commit 019d331

Please sign in to comment.