Skip to content

Commit

Permalink
Prototype implementation of an installation script
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <[email protected]>
  • Loading branch information
tdruez committed May 2, 2024
1 parent 58a45cc commit dcf4a88
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 0 deletions.
73 changes: 73 additions & 0 deletions docker-compose.latest.yml
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:
46 changes: 46 additions & 0 deletions etc/install.sh
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!"

0 comments on commit dcf4a88

Please sign in to comment.