Skip to content

Commit 3c26432

Browse files
committed
feat: Allow dynamic docker and rest api host
1 parent 757914e commit 3c26432

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

Vagrantfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Vagrant.configure("2") do |config|
3333
# Create a forwarded port mapping which allows access to a specific port
3434
# within the machine from a port on the host machine and only allow access
3535
# via 127.0.0.1 to disable public access
36+
config.vm.network "public_network", ip: "192.168.1.97"
3637
config.vm.network "forwarded_port", guest: 8080, host: 8080, host_ip: "127.0.0.1"
3738
config.vm.network "forwarded_port", guest: 3000, host: 3000, host_ip: "127.0.0.1"
3839
config.vm.network "forwarded_port", guest: 5000, host: 5000, host_ip: "127.0.0.1"

src/client/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"version": "1.0.0-Beta",
44
"private": true,
55
"homepage": "/",
6+
"restApi": "http://localhost:8080",
7+
"dockerApi": "ws://localhost:2375",
68
"dependencies": {
79
"@types/lodash": "^4.14.104",
810
"@types/react-redux": "^5.0.14",

src/client/src/AuthService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import decode from "jwt-decode";
2+
const config = require("../package.json");
3+
24
export default class AuthService {
35
// Initializing important variables
46

57
user: Object;
68
domain: string;
7-
// dockerApi: string;
89

910
constructor(domain?: string) {
10-
this.domain = domain || "http://localhost:8080"; // API server domain
11-
// this.dockerApi = "http://localhost:2375";
11+
this.domain = domain || config.restApi; // API server domain
1212
this.user = Object;
1313
this.fetch = this.fetch.bind(this); // React binding stuff
1414
this.login = this.login.bind(this);

src/client/src/components/CodeChillXterm.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as fit from "xterm/build/addons/fit/fit";
55
import * as ClassName from "classnames";
66
import AuthService from "../AuthService";
77
import withAuth from "./withAuth";
8+
var config = require("../../package.json");
89

910
export interface IxTermProps extends React.DOMAttributes<{}> {
1011
onChange?: (e: any) => void;
@@ -48,7 +49,7 @@ class CodeChillXterm extends React.Component<IxTermProps, IxTermState> {
4849
this.xterm = new Terminal();
4950
Terminal.applyAddon(attach);
5051
Terminal.applyAddon(fit);
51-
this.webSocket = new WebSocket(`ws://localhost:2375/containers/${this.props.user.dockers[0].name}/
52+
this.webSocket = new WebSocket(`${config.dockerApi}/containers/${this.props.user.dockers[0].name}/
5253
attach/ws?logs=0&stream=1&stdin=1&stdout=1&stderr=1`);
5354
this.Auth.startDocker(this.props.user.dockers[0].name).then((res) => {
5455
console.log(res);

0 commit comments

Comments
 (0)