forward arguments to portainer binary

This commit is contained in:
ngxson
2023-03-23 11:52:24 +01:00
parent 0eeb9a3e36
commit 06278098dc
3 changed files with 14 additions and 2 deletions

View File

@@ -9,4 +9,7 @@ WORKDIR /proxy
RUN npm i express http-proxy-middleware RUN npm i express http-proxy-middleware
COPY app.js . COPY app.js .
CMD ["node", "app.js"] COPY docker-entrypoint.sh /
ENTRYPOINT [ "/docker-entrypoint.sh" ]

8
app.js
View File

@@ -14,6 +14,7 @@ const INJECTED_HTML = `
const TARGET_URL = 'http://localhost:19000'; const TARGET_URL = 'http://localhost:19000';
const SSL_CERT_PATH = '/data/certs/cert.pem'; const SSL_CERT_PATH = '/data/certs/cert.pem';
const SSL_KEY_PATH = '/data/certs/key.pem'; const SSL_KEY_PATH = '/data/certs/key.pem';
const FORWARDED_ARGS = process.argv.slice(2);
// proxy logic // proxy logic
const app = express(); const app = express();
@@ -51,7 +52,12 @@ async function runServer() {
// child process for portainer // child process for portainer
function runPortainer() { function runPortainer() {
const child = spawn('/bin/sh', ['-c', '/portainer --bind=":19000" --bind-https=":19443"']); const fwdArgs = FORWARDED_ARGS.join(' ');
console.log(`Launching portainer with args ${fwdArgs}`)
const child = spawn('/bin/sh', [
'-c',
`/portainer --bind=":19000" --bind-https=":19443" ${fwdArgs}`
]);
child.stdout.pipe(process.stdout); child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr); child.stderr.pipe(process.stderr);
child.on('exit', function (code) { child.on('exit', function (code) {

3
docker-entrypoint.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/sh
node app.js "$@"