@@ -50,6 +50,15 @@ vm.max_map_count=262144
5050
5151Then run ` sudo sysctl -p ` to reload the kernel runtime parameters configuration.
5252
53+ ### Clone HealthyCode
54+
55+ ```
56+ git clone https://github.com/aboutcode-org/healthycode.git /opt/healthycode/ && cd /opt/healthycode/
57+ ```
58+
59+ Open ` /opt/healthycode/deploy/docker-compose/docker-compose-grimoirelab2.yml ` in a text editor,
60+ and set the credentials as suggested in following steps.
61+
5362### Ports and networks
5463
5564The main GrimoireLab services needed from outside its docker compose network
@@ -73,7 +82,7 @@ are minimally documented here.
7382
7483This various values for credentials are configured using environment variables
7584and defaults in docker compose file at:
76- docker-compose/docker-compose-grimoirelab2.yml
85+ ` /opt/healthycode/deploy/ docker-compose/docker-compose-grimoirelab2.yml`
7786
7887You can update that file as needed.
7988
@@ -108,93 +117,90 @@ NOTE that this is not a good practice for production services, yet only
108117containers inside this compose project can reach them.
109118
110119The good practice is to set passwords using the following variables for a
111- production enviroment :
120+ production environment :
112121
113- - For mariadb, set enviroment variables ending in:
122+ - For mariadb, set environment variables ending in:
114123 - ` *_DB_USER `
115124 - ` *_DB_PASSWORD `
116125
117- - For Valkey, set enviroment variables ending in:
126+ - For Valkey, set environment variables ending in:
118127 - ` *_REDIS_PASSWORD `
119128
120129## GrimoireLab Startup
121130
122- Once the initial configutaion above is completed, the next step if launch the
131+ Once the initial configuration above is completed, the next step if launch the
123132containers with these commands, from a clone of this repository:
124133
134+
125135```
126- cd docker-compose/
136+ cd /opt/healthycode/deploy/ docker-compose/
127137docker compose -f docker-compose-grimoirelab2.yml up -d
128138```
129139
130- ## Installation of with PurlDB and ScanCode.io
131-
132- ### Base installation
140+ ## Installation of PurlDB and ScanCode.io
133141
134142The first step is to install PurlDB and ScanCode.io using their standard
135143documentation.
136144
137- - Setup PurlDB using code and documentation at https://github.com/aboutcode-org/purldb
138-
139- Once completed, make sure that PurlDB is up and running.
140-
141-
142- - Setup ScanCode.io as a PurlDB scan worker using code and documentation at
143- https://github.com/aboutcode-org/scancode.io
144-
145- ### Add shared GrimoireLab docker network to ScanCode.io
146-
147- There is a temaplte for this docker network configuration in:
148- etc/scancodeio/network.yml. We copy that to the host:
145+ ### Install and setup PurlDB
149146
150147```
151- cd healthycode-deploy /
152- sudo cp ./etc/scancodeio/network.yml /etc/scancodeio/network.yml
148+ git clone https://github.com/aboutcode-org/purldb.git/ /opt/purldb/ && cd /opt/purldb /
149+ make envfile
153150```
154151
155- ### Edit ScanCode.io systemctl config to run with healthycode profile
152+ Open ` /opt/purldb/.env ` in a text editor and populate with this config:
156153
157154```
158- sudo vi /etc/systemd/system/scancodeio.service
155+ ALLOWED_HOSTS=<your host>
156+ SITE_URL=https://<your host>/
157+ PURLDB_PUBLIC_SETUP=True
158+ REST_API_ENDPOINTS=scan_queue,health,packages
159159```
160160
161- Update ExecStart as below:
161+ Build and run PurlDB
162162```
163- ExecStart=/usr/bin/docker compose \
164- -f /opt/scancodeio/docker-compose.purldb-scan-worker.yml \
165- -f /etc/scancodeio/networks.yml \
166- --profile healthycode \
167- up --scale worker=${NUM_WORKERS}
163+ sudo docker compose -f /opt/purldb/docker-compose.yml build
164+ sudo docker compose -f /opt/purldb/docker-compose.yml up -d
168165```
169166
167+ Once completed, make sure that PurlDB is up and running.
168+
169+
170+ ### Setup ScanCode.io as a PurlDB scan worker
171+
170172```
171- sudo systemctl daemon-reload
173+ git clone https://github.com/aboutcode-org/scancode.io.git /opt/scancodeio/ && cd /opt/scancodeio/
174+ make envfile
172175```
173176
174- ### Add PurlDB base URL and API key to ScanCode.io
177+ #### Add PurlDB base URL and API key to ScanCode.io
175178
176179Get or create a PurlDB API key for the scanworker:
177180```
178- # on purldb
179- docker compose -f /opt/purldb/docker-compose.production.yml exec web python \
180- manage_purldb.py create-scan-queue-worker-user <username>
181+ sudo docker compose -f /opt/purldb/docker-compose.yml exec web purldb \
182+ create-scan-queue-worker-user scancode-worker <username>
181183```
182184
185+ Copy the scancode-worker API Key, and open ` /opt/scancodeio/.env ` in a text editor.
186+
183187```
184- sudo vi /etc /scancodeio/.env
188+ sudo vi /opt /scancodeio/.env
185189```
186190
187- Populate with this config, using localhost assuming eveything is co-located on
191+ Populate with this config, using localhost assuming everything is co-located on
188192one server:
193+
189194```
190- PURLDB_URL=
191- PURLDB_API_KEY="scanworker -api-key"
195+ PURLDB_URL=<your host>
196+ PURLDB_API_KEY="scancode-worker -api-key"
192197```
193198
194- ### Configure GrimoireLab environment in ScanCode.io
199+
200+ #### Configure GrimoireLab environment in ScanCode.io
195201
196202```
197- sudo vi /etc /scancodeio/.env
203+ sudo vi /opt /scancodeio/.env
198204```
199205
200206Populate with this config:
@@ -203,20 +209,27 @@ GRIMOIRELAB_URL="http://grimoirelab-nginx:8000/"
203209GRIMOIRELAB_OPENSEARCH_URL="https://grimoirelab-opensearch:9200/"
204210GRIMOIRELAB_ECOSYSTEM="npmlargerecosystem"
205211GRIMOIRELAB_PROJECT="NPMMostUsed"
212+ GRIMOIRELAB_OPENSEARCH_INDEX="events"
206213```
207214
208215Populate these fields based on the same secret that may have been set in
209- ` . /docker-compose/docker-compose-grimoirelab2.yml`
216+ ` /opt/healthycode/deploy /docker-compose/docker-compose-grimoirelab2.yml`
210217
211218```
219+ # Populate this using value from GRIMOIRELAB_SUPERUSER_USERNAME
220+ # and GRIMOIRELAB_SUPERUSER_PASSWORD set earlier in
221+ # /opt/healthycode/deploy/docker-compose/docker-compose-grimoirelab2.yml
212222GRIMOIRELAB_USERNAME=""
213223GRIMOIRELAB_PASSWORD=""
214- GRIMOIRELAB_OPENSEARCH_INDEX=""
224+
225+ # Populate this using value from GRIMOIRELAB_ARCHIVIST_STORAGE_USERNAME
226+ # and GRIMOIRELAB_ARCHIVIST_STORAGE_PASSWORD set earlier in
227+ # /opt/healthycode/deploy/docker-compose/docker-compose-grimoirelab2.yml
215228GRIMOIRELAB_OPENSEARCH_USERNAME=""
216229GRIMOIRELAB_OPENSEARCH_PASSWORD=""
217230```
218231
219- ### Expose ScanCode.io on port 8443
232+ #### Expose ScanCode.io on port 8443
220233
221234This is optional, and enables access to the ScanCode.io scan worker.
222235If using this, make sure you configure authentication in ScanCode.io first.
@@ -227,19 +240,125 @@ sudo vi /opt/scancodeio/.env
227240
228241Add the below env variables:
229242```
243+ ALLOWED_HOSTS=<your host>
244+ CSRF_TRUSTED_ORIGINS=https://<your host>:8443
245+
230246NGINX_PUBLISHED_HTTP_PORT=8081
231247NGINX_PUBLISHED_HTTPS_PORT=8443
232248```
233249
234- ### Restart ScanCode.io
250+ If this is enabled ScanCode.io will be accessible at: ` http://<your host>:8443 `
251+
252+
253+ #### Start ScanCode.io
254+
255+ Remove any old healthycode volume.
256+
257+ ```
258+ docker volume rm scancodeio_healthycode_venv
259+ ```
260+
261+ Pull prebuilt ScanCode docker images
262+
235263```
236- sudo systemctl restart scancodeio
264+ sudo docker compose -f /opt/ scancodeio/docker-compose.purldb-scan-worker.yml pull
237265```
238266
267+ Start ScanCode with HealthyCode profile
268+
269+ ```
270+ sudo docker compose \
271+ -f /opt/scancodeio/docker-compose.purldb-scan-worker.yml \
272+ -f /opt/healthycode/deploy/etc/scancodeio/networks.yml \
273+ --profile healthycode \
274+ up --scale worker=2 -d
275+ ```
276+
277+ Note: we attach shared GrimoireLab network to ScanCode service using ` networks.yml `
278+
239279## Verify everything is working end to end
240280
241281
242- Visit the PurlDB health API at: https://<your host >/api/health/
282+ Visit the PurlDB health API at: ` https://<your host>/api/health/ `
283+
284+ Make a test request with ` https://<your host>/api/health/?purl=pkg:npm/lodash&format=json `
285+
286+
287+ ## Some useful commands
288+
289+ ### Start and Stop ScanCode.io service
290+
291+ Start ScanCode.io
292+
293+ ```
294+ sudo docker compose \
295+ -f /opt/scancodeio/docker-compose.purldb-scan-worker.yml \
296+ -f /opt/healthycode/deploy/etc/scancodeio/networks.yml \
297+ --profile healthycode \
298+ up --scale worker=2 -d
299+ ```
300+
301+ Stop ScanCode.io:
302+
303+ ```
304+ sudo docker compose -f /opt/scancodeio/docker-compose.purldb-scan-worker.yml down
305+ ```
306+
307+ ### Start and Stop PurlDB service
308+
309+ Start PurlDB:
310+
311+ ```
312+ sudo docker compose -f /opt/purldb/docker-compose.yml up -d
313+ ```
314+
315+ Stop PurlDB:
316+
317+ ```
318+ sudo docker compose -f /opt/purldb/docker-compose.yml down
319+ ```
320+
321+ ### Start and Stop GrimoireLab service
322+
323+ Start GrimoireLab:
324+
325+ ```
326+ docker compose -f /opt/healthycode/deploy/docker-compose/docker-compose-grimoirelab2.yml up -d
327+ ```
328+
329+ Stop GrimoireLab:
330+
331+ ```
332+ docker compose -f /opt/healthycode/deploy/docker-compose/docker-compose-grimoirelab2.yml down
333+ ```
334+
335+
336+ ## Enable authentication for ScanCode.io (Optional):
337+
338+ Add this to ` /opt/scancodeio/.env `
339+
340+ ```
341+ SCANCODEIO_REQUIRE_AUTHENTICATION=True
342+ ```
343+
344+ Run this command to create username and password required to login to ScanCode:
345+
346+ ```
347+ docker compose -f /opt/scancodeio/docker-compose.yml exec web ./manage.py scanpipe create-user <user-name>
348+ ```
349+
350+ Restart ScanCode.io service.
351+
352+ ## SSL/TLS Configuration
353+
354+ Add ` fullchain.pem ` and ` privkey.pem ` for your host inside:
355+
356+ - /opt/purldb/etc/nginx/conf.d/
357+ - /opt/scancodeio/etc/nginx/conf.d/
358+
359+ Restart PurlDB and ScanCode.io service.
243360
244- Make a test request with https://< your host >/api/health/?purl=pkg : npm /lodash&format=json
361+ ## Reference documentation
245362
363+ - https://scancodeio.readthedocs.io/en/latest/installation.html
364+ - https://purldb.readthedocs.io/en/latest/getting-started/install.html
0 commit comments