Skip to content

Commit 9a8db4b

Browse files
authored
Merge pull request #854 from eclipsesource/documentation-and-setup
docker compose file and extended documentation
2 parents 71941ca + c2db736 commit 9a8db4b

File tree

6 files changed

+176
-15
lines changed

6 files changed

+176
-15
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ After you created the GitHub OAuth app, the next step is to copy the _Client ID_
6262

6363
With these settings in place, you should be able to log in by authorizing your OAuth app.
6464

65+
### Docker Compose Setup
66+
67+
If you prefer to quickly get started with a local, docker-based development environment, you can use the approach described in our [docker compose setup](doc/development.md#using-docker-compose).
68+
You can use our docker compose profiles, allowing you the option to either run a service directly in a docker container or to manually build and run it on your local machine.
69+
6570
### Google Cloud Setup
6671

6772
If you would like to test file storage via Google Cloud, follow these steps:

cli/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@
6161
"lint": "eslint -c ./configs/eslintrc.json --ext .ts src",
6262
"prepare": "yarn run clean && yarn run build",
6363
"publish:next": "yarn npm publish --tag next",
64-
"publish:latest": "yarn npm publish --tag latest"
64+
"publish:latest": "yarn npm publish --tag latest",
65+
"load-extensions": "node scripts/load-test-extensions.js"
6566
},
6667
"packageManager": "yarn@4.1.0"
6768
}

cli/scripts/load-test-extensions.js

+18-10
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if (process.argv.length >= 4) {
2626

2727
async function loadTestExtensions() {
2828
const publicReg = new Registry();
29-
const localReg = new Registry({url: 'http://localhost:8080'});
29+
const localReg = new Registry({registryUrl: process.env.OVSX_REGISTRY_URL ?? 'http://localhost:8080'});
3030
/** @type {{ extensions: import('../lib/registry').Extension[] } & import('../lib/registry').Response} */
3131
const search = await publicReg.getJson(new URL(`${DEFAULT_URL}/api/-/search?size=${searchSize}`));
3232
if (search.error) {
@@ -41,17 +41,25 @@ async function loadTestExtensions() {
4141
continue;
4242
}
4343
const fileName = await download(publicReg, meta);
44-
const nsResult = await localReg.createNamespace(meta.namespace, accessToken);
45-
if (nsResult.error && !nsResult.error.startsWith('Namespace already exists')) {
46-
console.error(nsResult.error);
47-
} else if (nsResult.success) {
48-
console.log(nsResult.success);
44+
try {
45+
const nsResult = await localReg.createNamespace(meta.namespace, accessToken);
46+
console.log(nsResult.success);
47+
} catch (error) {
48+
if (!error.message.startsWith('Namespace already exists')) {
49+
console.error(error);
50+
process.exit(1);
51+
}
4952
}
50-
const published = await localReg.publish(fileName, accessToken);
51-
if (published.error && !published.error.endsWith('is already published.')) {
52-
console.error(`\u274c ${published.error}`);
53-
} else if (published.namespace && published.name) {
53+
54+
try {
55+
const published = await localReg.publish(fileName, accessToken);
56+
if (published.namespace && published.name) {
5457
console.log(`\u2713 Published ${published.namespace}.${published.name}@${published.version}`);
58+
}
59+
} catch (error) {
60+
if (!error.message.endsWith('is already published.')) {
61+
console.error(`\u274c ${error}`);
62+
}
5563
}
5664
}
5765
}

doc/development.md

+40-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,29 @@ To get started quickly, it is recommended to use Gitpod as default with the deve
66

77
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/eclipse/openvsx)
88

9+
### Using Docker Compose
10+
11+
To run the Open VSX registry in a development environment, you can use `docker compose` by following these steps:
12+
13+
* Verify Docker Compose is installed by running `docker compose version`. If an error occurs, you may need to [install docker compose](https://docs.docker.com/compose/install/) on your machine.
14+
* Decide which profile(s) to run based on your needs. By default, only the PostgreSQL and Elasticsearch containers start, which suits running the OpenVSX server and web UI locally for easier debugging. The [docker-compose.yml] file defines additional profiles for specific components:
15+
* `backend`: Starts the OpenVSX server container (java).
16+
* `frontend`: Starts the web UI container.
17+
* `commandline`: Starts a container with the OpenVSX CLI tools.
18+
* `openvsx`: Combines `backend`, `frontend`, and `commandline` profiles to start all related services.
19+
* `kibana`: Starts a kibana instance for easier access to the Elasticsearch service.
20+
* In the project root, initiate Docker Compose:
21+
* Without profiles: `docker compose up`.
22+
* With profiles: `docker compose --profile <profile_name> up`. Use multiple `--profile` flags for multiple profiles, e.g., `docker compose --profile openvsx --profile kibana up`.
23+
24+
* Depending on which profile(s) you selected, after some seconds, the respective services become available:
25+
* registry backend is available at [http://localhost:8080/](http://localhost:8080/) if the `backend` or `openvsx` profile was selected.
26+
* web ui is available at [http://localhost:3000/](http://localhost:3000/) if the `frontend` or `openvsx` profile was selected.
27+
* kibana is exposed at [http://localhost:5601/](http://localhost:5601/) if the `kibana` profile was selected.
28+
* Open VSX CLI commands can be run via `docker compose exec cli lib/ovsx` if the `commandline` or `openvsx` profile was selected.
29+
* To load some extensions from the main registry (openvsx.org), run `docker compose exec cli yarn load-extensions <N>`, where N is the number of extensions you would like to publish in your local registry.
30+
* For troubleshooting or manual intervention, access a service's interactive shell with `docker compose run --rm <service> /bin/bash`. Service names are listed in the [docker-compose.yml](docker-compose.yml) file.
31+
932
### Setup locally on WSL
1033

1134
- Install WSL
@@ -96,7 +119,7 @@ To get started quickly, it is recommended to use Gitpod as default with the deve
96119

97120
- Download the Elasticsearch image from Docker Hub and enable it in the Docker Desktop
98121

99-
### Run the application
122+
### Run the application locally
100123

101124
- cd cli
102125

@@ -115,3 +138,19 @@ To get started quickly, it is recommended to use Gitpod as default with the deve
115138
- yarn build:default
116139
- yarn start:default
117140
- Go to localhost:3000 on browser and it should be up and running
141+
142+
### Optional: Deploy example extensions to your local registry
143+
144+
Run:
145+
146+
- in `server/`:
147+
`gradlew downloadTestExtensions` to download vsix files from the official store and from Github.
148+
- in project root (the server application must be running):
149+
```bash
150+
export OVSX_REGISTRY_URL=http://localhost:8080
151+
export OVSX_PAT=super_token
152+
export PUBLISHERS="DotJoshJohnson eamodio felixfbecker formulahendry HookyQR ms-azuretools ms-mssql ms-python ms-vscode octref redhat ritwickdey sburg vscode vscodevim Wscats"
153+
for pub in $PUBLISHERS; do cli/lib/ovsx create-namespace $pub; done
154+
find server/build/test-extensions-builtin -name '*.vsix' -exec cli/lib/ovsx publish '{}' \;
155+
find server/build/test-extensions -name '*.vsix' -exec cli/lib/ovsx publish '{}' \;
156+
```

docker-compose.yml

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
services:
2+
3+
postgres:
4+
image: postgres:latest
5+
environment:
6+
- POSTGRES_USER=openvsx
7+
- POSTGRES_PASSWORD=openvsx
8+
logging:
9+
options:
10+
max-size: 10m
11+
max-file: "3"
12+
ports:
13+
- '5432:5432'
14+
15+
elasticsearch:
16+
image: elasticsearch:8.7.1
17+
environment:
18+
- xpack.security.enabled=false
19+
- xpack.ml.enabled=false
20+
- discovery.type=single-node
21+
- bootstrap.memory_lock=true
22+
- cluster.routing.allocation.disk.threshold_enabled=false
23+
ports:
24+
- 9200:9200
25+
- 9300:9300
26+
healthcheck:
27+
test: curl -s http://elasticsearch01:9200 >/dev/null || exit 1
28+
interval: 10s
29+
timeout: 5s
30+
retries: 50
31+
start_period: 5s
32+
33+
kibana:
34+
image: kibana:8.7.1
35+
ports:
36+
- "5601:5601"
37+
environment:
38+
- ELASTICSEARCH_URL=http://elasticsearch:9200
39+
depends_on:
40+
- elasticsearch
41+
profiles:
42+
- kibana
43+
44+
server:
45+
image: openjdk:17
46+
working_dir: /app
47+
command: sh -c 'scripts/generate-properties.sh --docker && ./gradlew assemble && ./gradlew runServer'
48+
volumes:
49+
- ./server:/app
50+
ports:
51+
- 8080:8080
52+
depends_on:
53+
- postgres
54+
- elasticsearch
55+
healthcheck:
56+
test: "curl --fail --silent localhost:8081/actuator/health | grep UP || exit 1"
57+
interval: 10s
58+
timeout: 5s
59+
retries: 50
60+
start_period: 5s
61+
profiles:
62+
- openvsx
63+
- backend
64+
65+
webui:
66+
image: node:18
67+
working_dir: /app
68+
command: sh -c 'yarn && yarn build && yarn build:default && yarn start:default'
69+
volumes:
70+
- ./webui:/app
71+
ports:
72+
- 3000:3000
73+
depends_on:
74+
- server
75+
profiles:
76+
- openvsx
77+
- frontend
78+
79+
cli:
80+
image: node:18
81+
working_dir: /app
82+
command: sh -c 'yarn && yarn watch'
83+
volumes:
84+
- ./cli:/app
85+
depends_on:
86+
- server
87+
environment:
88+
- OVSX_REGISTRY_URL=http://server:8080
89+
profiles:
90+
- openvsx
91+
- commandline

server/scripts/generate-properties.sh

+20-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
1-
#!/bin/sh
1+
#!/bin/bash
2+
3+
INSIDE_DOCKER=false
4+
if [[ $* == *--docker* ]]
5+
then
6+
INSIDE_DOCKER=true;
7+
fi
28

39
# This script must be run from the 'server' directory
410
export OVSX_APP_PROFILE=$PWD/src/dev/resources/application-ovsx.properties
511

612
# Clear the content of the ovsx application profile
713
echo "# Generated by scripts/generate-properties.sh" > $OVSX_APP_PROFILE
814

9-
# Set the Elasticsearch host
10-
echo "ovsx.elasticsearch.host=localhost:9200" >> $OVSX_APP_PROFILE
15+
if [ "$INSIDE_DOCKER" = true ]
16+
then
17+
# Set the Elasticsearch host
18+
echo "ovsx.elasticsearch.host=elasticsearch:9200" >> $OVSX_APP_PROFILE
19+
20+
# Set the Postgres host
21+
echo "spring.datasource.url=jdbc:postgresql://postgres:5432/postgres" >> $OVSX_APP_PROFILE
22+
echo "spring.datasource.username=openvsx" >> $OVSX_APP_PROFILE
23+
echo "spring.datasource.password=openvsx" >> $OVSX_APP_PROFILE
24+
else
25+
# Set the Elasticsearch host
26+
echo "ovsx.elasticsearch.host=localhost:9200" >> $OVSX_APP_PROFILE
27+
fi
1128

1229
# Set the web UI URL
1330
if command -v gp > /dev/null

0 commit comments

Comments
 (0)