Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/config/env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { GIT_PROXY_SERVER_PORT = 8000, GIT_PROXY_UI_PORT = 8080 } = process.env;

exports.Vars = { GIT_PROXY_SERVER_PORT, GIT_PROXY_UI_PORT };
2 changes: 1 addition & 1 deletion src/proxy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const bodyParser = require('body-parser');
const routes = require('./routes');
const config = require('../config');
const db = require('../db');
const proxyHttpPort = 8000;
const { GIT_PROXY_SERVER_PORT: proxyHttpPort } = require('../config/env').Vars;

const options = {
inflate: true,
Expand Down
4 changes: 3 additions & 1 deletion src/proxy/processors/push-action/blockForAuth.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
const Step = require('../../actions').Step;

const { GIT_PROXY_UI_PORT: uiPort } = require('../../../config/env').Vars;

const exec = async (req, action) => {
const step = new Step('authBlock');

const message =
'\n\n\n' +
`Git Proxy has received your push:\n\n` +
`http://localhost:8080/requests/${action.id}` +
`http://localhost:${uiPort}/requests/${action.id}` +
'\n\n\n';
step.setAsyncBlock(message);
action.addStep(step);
Expand Down
7 changes: 4 additions & 3 deletions src/service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ const session = require('express-session');
const http = require('http');
const cors = require('cors');
const app = express();
const port = 8080;

const { GIT_PROXY_UI_PORT: uiPort } = require('../config/env').Vars;

const _httpServer = http.createServer(app);

Expand Down Expand Up @@ -33,9 +34,9 @@ const start = async () => {
app.use(express.urlencoded({ extended: true }));
app.use('/', routes);

await _httpServer.listen(port);
await _httpServer.listen(uiPort);

console.log(`Service Listening on ${port}`);
console.log(`Service Listening on ${uiPort}`);
app.emit('ready');

return app;
Expand Down
5 changes: 3 additions & 2 deletions src/ui/services/git-push.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/* eslint-disable max-len */
/* eslint-disable require-jsdoc */
import axios from 'axios';
const baseUrl = 'http://localhost:8080/api/v1';
const { GIT_PROXY_UI_PORT: uiPort } = require('../../config/env').Vars;
const baseUrl = `http://localhost:${uiPort}/api/v1`;

const config = {
withCredentials: true,
};

const getUser = async (setIsLoading, setData, setAuth, setIsError) => {
const url = new URL(`http://localhost:8080/auth/success`);
const url = new URL(`http://localhost:${uiPort}/auth/success`);
await axios(url.toString(), config)
.then((response) => {
const data = response.data;
Expand Down
3 changes: 2 additions & 1 deletion src/ui/services/repo.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable max-len */
/* eslint-disable require-jsdoc */
import axios from 'axios';
const baseUrl = 'http://localhost:8080/api/v1';
const { GIT_PROXY_UI_PORT: uiPort } = require('../../config/env').Vars;
const baseUrl = `http://localhost:${uiPort}/api/v1`;

const config = {
withCredentials: true,
Expand Down
3 changes: 2 additions & 1 deletion src/ui/services/user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable max-len */
/* eslint-disable require-jsdoc */
import axios from 'axios';
const baseUrl = 'http://localhost:8080';
const { GIT_PROXY_UI_PORT: uiPort } = require('../../config/env').Vars;
const baseUrl = `http://localhost:${uiPort}/api/v1`;

const config = {
withCredentials: true,
Expand Down
5 changes: 4 additions & 1 deletion src/ui/views/Login/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ const styles = {
},
};

const { GIT_PROXY_UI_PORT: uiPort } = require('../../config/env').Vars;
const baseUrl = `http://localhost:${uiPort}`;

const useStyles = makeStyles(styles);

export default function UserProfile() {
Expand All @@ -54,7 +57,7 @@ export default function UserProfile() {
function handleSubmit(event) {
axios
.post(
'http://localhost:8080/auth/login',
`${baseUrl}/auth/login`,
{
username: username,
password: password,
Expand Down
13 changes: 13 additions & 0 deletions website/docs/configuration/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ Or with npx:
npx -- @finos/git-proxy --config ./config.json
```

### Set ports with ENV variables
By default, Git Proxy uses port 8000 to expose the Git Server and 8080 for the frontend application.
The ports can be changed by setting the `GIT_PROXY_SERVER_PORT` and `GIT_PROXY_UI_PORT`
environment variables:

```
export GIT_PROXY_UI_PORT="5000"
export GIT_PROXY_SERVER_PORT="9090"
```

Note that `GIT_PROXY_UI_PORT` is needed for both server and UI Node processes,
whereas `GIT_PROXY_SERVER_PORT` is only needed by the server process.

### Validate configuration

To validate your Git Proxy configuration, run:
Expand Down