-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prototype implementation of an installation script
Signed-off-by: tdruez <[email protected]>
- Loading branch information
Showing
2 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
services: | ||
db: | ||
image: postgres:13 | ||
env_file: | ||
- docker.env | ||
volumes: | ||
- db_data:/var/lib/postgresql/data/ | ||
shm_size: "1gb" | ||
restart: always | ||
|
||
redis: | ||
image: redis | ||
# Enable redis data persistence using the "Append Only File" with the | ||
# default policy of fsync every second. See https://redis.io/topics/persistence | ||
command: redis-server --appendonly yes | ||
volumes: | ||
- redis_data:/data | ||
restart: always | ||
|
||
web: | ||
image: ghcr.io/nexb/scancode.io:latest | ||
command: wait-for-it --strict --timeout=60 db:5432 -- sh -c " | ||
./manage.py migrate && | ||
./manage.py collectstatic --no-input --verbosity 0 --clear && | ||
gunicorn scancodeio.wsgi:application --bind :8000 --timeout 600 --workers 8" | ||
env_file: | ||
- docker.env | ||
expose: | ||
- 8000 | ||
volumes: | ||
- .env:/opt/scancodeio/.env | ||
- /etc/scancodeio/:/etc/scancodeio/ | ||
- workspace:/var/scancodeio/workspace/ | ||
- static:/var/scancodeio/static/ | ||
depends_on: | ||
- db | ||
|
||
worker: | ||
image: ghcr.io/nexb/scancode.io:latest | ||
# Ensure that potential db migrations run first by waiting until "web" is up | ||
command: wait-for-it --strict --timeout=120 web:8000 -- sh -c " | ||
./manage.py rqworker --worker-class scancodeio.worker.ScanCodeIOWorker | ||
--queue-class scancodeio.worker.ScanCodeIOQueue | ||
--verbosity 1" | ||
env_file: | ||
- docker.env | ||
volumes: | ||
- .env:/opt/scancodeio/.env | ||
- /etc/scancodeio/:/etc/scancodeio/ | ||
- workspace:/var/scancodeio/workspace/ | ||
depends_on: | ||
- redis | ||
- db | ||
- web | ||
|
||
nginx: | ||
image: nginx:alpine | ||
ports: | ||
- "${NGINX_PUBLISHED_HTTP_PORT:-80}:80" | ||
- "${NGINX_PUBLISHED_HTTPS_PORT:-443}:443" | ||
volumes: | ||
- ./etc/nginx/conf.d/:/etc/nginx/conf.d/ | ||
- /var/www/html:/var/www/html | ||
- static:/var/scancodeio/static/ | ||
depends_on: | ||
- web | ||
restart: always | ||
|
||
volumes: | ||
db_data: | ||
redis_data: | ||
static: | ||
workspace: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) nexB Inc. and others. All rights reserved. | ||
# DejaCode is a trademark of nexB Inc. | ||
# SPDX-License-Identifier: AGPL-3.0-only | ||
# See https://github.com/nexB/dejacode for support or download. | ||
# See https://aboutcode.org for more information about AboutCode FOSS projects. | ||
# | ||
|
||
# Usage: | ||
# /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/nexB/scancode.io/install-sh/etc/install.sh)" | ||
|
||
INSTALL_LOCATION=${HOME}/.scancodeio | ||
ENV_FILE=${INSTALL_LOCATION}/.env | ||
DOCKER_COMPOSE_URL="https://raw.githubusercontent.com/nexB/scancode.io/install-sh/docker-compose.latest.yml" | ||
DOCKER_ENV_URL="https://raw.githubusercontent.com/nexB/scancode.io/install-sh/docker.env" | ||
DOCKER_COMPOSE_FILE=${INSTALL_LOCATION}/docker-compose.yml | ||
DOCKER_ENV_FILE=${INSTALL_LOCATION}/docker.env | ||
DOCKER_COMPOSE="docker compose -f ${DOCKER_COMPOSE_FILE}" | ||
DOCKER_VOLUMES="--volume ${INSTALL_LOCATION}:/var/scancodeio/workspace/" | ||
SCANPIPE_CMD="${DOCKER_COMPOSE} run ${DOCKER_VOLUMES} --rm web scanpipe" | ||
|
||
# Create the ~/.scancodeio directory in home | ||
mkdir -p ${INSTALL_LOCATION} | ||
|
||
# Generate the environment file | ||
if [ ! -f "${ENV_FILE}" ]; then | ||
echo "-> Create the .env file and generate a secret key" | ||
touch ${ENV_FILE} | ||
echo SECRET_KEY=\"TODO\" > ${ENV_FILE} | ||
fi | ||
|
||
# Fetch the docker-compose.yml and docker.env files | ||
curl --output ${DOCKER_COMPOSE_FILE} ${DOCKER_COMPOSE_URL} | ||
curl --output ${DOCKER_ENV_FILE} ${DOCKER_ENV_URL} | ||
|
||
# Run a test command | ||
${SCANPIPE_CMD} create-project test_project | ||
|
||
#${SCANPIPE_CMD} create-project ackage-url \ | ||
# --input-url https://github.com/package-url/packageurl-js/archive/refs/tags/v1.2.1.zip \ | ||
# --pipeline scan_codebase \ | ||
# --execute | ||
#${SCANPIPE_CMD} shell | ||
|
||
echo "Installation completed!" |