Added docker support, made config dynamic (#108)
* Made config.json dynamic
* added docker support
* Fixed dockerfile npm install error
* fixed line ends
* Revert "Made config.json dynamic"
This reverts commit 5cb413b9aa
.
* config.json is now loaded dynamically
* Made dynamic config work on github page
* config is now dynamically copied
* removed sync-request dependency
Co-authored-by: d513 <ogoniasty513@gmail.com>
This commit is contained in:
parent
cec8f176f1
commit
4d4b32e8de
5 changed files with 29 additions and 7 deletions
5
.dockerignore
Normal file
5
.dockerignore
Normal file
|
@ -0,0 +1,5 @@
|
|||
# we dont want default config to be loaded in the dockerfile, but rather using a volume
|
||||
config.json
|
||||
# build stuff
|
||||
node_modules
|
||||
public
|
9
Dockerfile
Normal file
9
Dockerfile
Normal file
|
@ -0,0 +1,9 @@
|
|||
FROM node:14-alpine
|
||||
# Without git installing the npm packages fails
|
||||
RUN apk add git
|
||||
RUN mkdir /app
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
RUN npm install
|
||||
RUN npm run build
|
||||
ENTRYPOINT ["npm", "run", "prod-start"]
|
17
lib/menu.js
17
lib/menu.js
|
@ -1,17 +1,22 @@
|
|||
const { LitElement, html, css } = require('lit-element')
|
||||
const config = require('../config.json')
|
||||
require('./github_link')
|
||||
|
||||
/* global fetch */
|
||||
class PrismarineMenu extends LitElement {
|
||||
constructor () {
|
||||
super()
|
||||
|
||||
this.server = config.defaultHost
|
||||
this.serverport = config.defaultHostPort ?? 25565
|
||||
this.proxy = config.defaultProxy
|
||||
this.proxyport = !config.defaultProxy && !config.defaultProxyPort ? '' : config.defaultProxyPort ?? 443
|
||||
this.server = ''
|
||||
this.serverport = 25565
|
||||
this.proxy = ''
|
||||
this.proxyport = ''
|
||||
this.username = window.localStorage.getItem('username') ?? 'pviewer' + (Math.floor(Math.random() * 1000))
|
||||
this.password = ''
|
||||
fetch('config.json').then(res => res.json()).then(config => {
|
||||
this.server = config.defaultHost
|
||||
this.serverport = config.defaultHostPort ?? 25565
|
||||
this.proxy = config.defaultProxy
|
||||
this.proxyport = !config.defaultProxy && !config.defaultProxyPort ? '' : config.defaultProxyPort ?? 443
|
||||
})
|
||||
}
|
||||
|
||||
static get properties () {
|
||||
|
|
|
@ -8,6 +8,8 @@ const path = require('path')
|
|||
// Create our app
|
||||
const app = express()
|
||||
|
||||
app.get('/config.json', (_, res) => res.sendFile(path.join(__dirname, 'config.json')))
|
||||
|
||||
app.use(compression())
|
||||
app.use(netApi({ allowOrigin: '*' }))
|
||||
if (process.argv[3] === 'dev') {
|
||||
|
|
|
@ -73,7 +73,8 @@ const config = {
|
|||
{ from: path.join(__dirname, '/node_modules/prismarine-viewer/public/worker.js'), to: './' },
|
||||
{ from: path.join(__dirname, '/node_modules/prismarine-viewer/public/supportedVersions.json'), to: './' },
|
||||
{ from: path.join(__dirname, 'assets/'), to: './' },
|
||||
{ from: path.join(__dirname, 'extra-textures/'), to: './extra-textures/' }
|
||||
{ from: path.join(__dirname, 'extra-textures/'), to: './extra-textures/' },
|
||||
{ from: path.join(__dirname, 'config.json'), to: './config.json' }
|
||||
]
|
||||
})
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue