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
26 changes: 20 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,32 @@
# See https://github.com/nexB/federatedcode for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#
FROM python:3.10

FROM python:3.10-slim

ENV APP_NAME federatedcode
ENV APP_DIR /opt/$APP_NAME

# Python settings: Force unbuffered stdout and stderr (i.e. they are flushed to terminal immediately)
ENV PYTHONUNBUFFERED 1
# Python settings: do not write pyc files
ENV PYTHONDONTWRITEBYTECODE 1
# Add the app dir in the Python path for entry points availability
ENV PYTHONPATH $PYTHONPATH:$APP_DIR

RUN pip install --upgrade pip
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
wait-for-it \
git \
&& apt-get clean \
&& rm -rf /tmp/* /var/tmp/*

WORKDIR /federatedcode
WORKDIR $APP_DIR

COPY requirements.txt pyproject.toml /federatedcode/
RUN mkdir -p /var/$APP_NAME/static/

RUN pip install -r requirements.txt
# Keep the dependencies installation before the COPY of the app/ for proper caching
COPY setup.cfg setup.py requirements.txt pyproject.toml $APP_DIR/
RUN pip install . -c requirements.txt

COPY . /federatedcode
COPY . $APP_DIR
26 changes: 19 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,28 @@ security information.
Quick Installation
--------------------

Run with Docker
~~~~~~~~~~~~~~~


Clone FederatedCode::

git clone https://github.com/aboutcode-org/federatedcode.git
cd federatedcode

Build and run::

docker compose build
docker compose up


Local development installation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

On a Debian system, use this::

sudo apt-get install python3-venv python3-dev postgresql libpq-dev build-essential
git clone https://github.com/nexB/federatedcode.git
git clone https://github.com/aboutcode-org/federatedcode.git
cd federatedcode
make dev envfile postgresdb
make test
Expand Down Expand Up @@ -163,9 +181,3 @@ funding is made available by the Swiss State Secretariat for Education, Research
:target: https://nlnet.nl/discovery/
:height: 40
:alt: NGI Discovery logo






42 changes: 22 additions & 20 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@
version: '3'

services:
federatedcode_db:
image: postgres:16
db:
image: postgres:13
env_file:
- docker.env
volumes:
- federatedcode_db_data:/var/lib/postgresql/data/
- db_data:/var/lib/postgresql/data/

federatedcode:
web:
build: .
command: /bin/sh -c "
apt-get update && apt-get install -y gunicorn &&
python manage.py collectstatic --no-input --verbosity 0 --clear &&
python manage.py migrate &&
gunicorn federatedcode.wsgi:application -u nobody -g nogroup --bind :8000 --timeout 600 --workers 8"
command: wait-for-it --strict --timeout=60 db:5432 -- sh -c "
./manage.py migrate &&
./manage.py collectstatic --no-input --verbosity 0 --clear &&
gunicorn federatedcode.wsgi:application --bind :8000 --timeout 600 --workers 8"
env_file:
- docker.env
expose:
- 8000
ports:
- "8000:8000"
volumes:
- static:/var/federatedcode/static/
- /etc/federatedcode/:/etc/federatedcode/
- static:/var/federatedcode/static/
- workspace:/var/federatedcode/workspace/
depends_on:
- federatedcode_db
- db

federatedcode_nginx:
nginx:
image: nginx
ports:
- 80:80
- 443:443
env_file:
- docker.env
volumes:
- ./etc/nginx/conf.d/:/etc/nginx/conf.d
- ./etc/nginx/conf.d/:/etc/nginx/conf.d/
- static:/var/federatedcode/static/
- /var/www/html:/var/www/html
depends_on:
- federatedcode
- web

volumes:
federatedcode_db_data:
federatedcode_static:
federatedcode:

db_data:
static:
workspace:
10 changes: 8 additions & 2 deletions docker.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
FEDERATEDCODE_WORKSPACE_LOCATION=/var/federatedcode
POSTGRES_DB=federatedcode
POSTGRES_USER=federatedcode
POSTGRES_PASSWORD=federatedcode

FEDERATEDCODE_DB_HOST=db
FEDERATEDCODE_STATIC_ROOT=/var/federatedcode/static/

FEDERATEDCODE_WORKSPACE_LOCATION=/var/federatedcode/workspace/
FEDERATEDCODE_CLIENT_ID=""
FEDERATEDCODE_CLIENT_SECRET=""
NGINX_PORT=8080
4 changes: 3 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "federatedcode.settings")
os.environ.setdefault("SECRET_KEY", "dummy secret key for autodoc rtd documentation")
os.environ.setdefault("FEDERATEDCODE_CLIENT_ID", "dummy secret key for autodoc rtd documentation")
os.environ.setdefault("FEDERATEDCODE_CLIENT_SECRET", "dummy secret key for autodoc rtd documentation")
os.environ.setdefault(
"FEDERATEDCODE_CLIENT_SECRET", "dummy secret key for autodoc rtd documentation"
)

sys.path.insert(0, os.path.abspath("../../."))

Expand Down
2 changes: 1 addition & 1 deletion etc/nginx/conf.d/default.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
upstream gunicorn_app {
server federatedcode:8000;
server web:8000;
}

server {
Expand Down
5 changes: 2 additions & 3 deletions federatedcode/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# See https://github.com/nexB/federatedcode for support or download.
# See https://aboutcode.org for more information about AboutCode.org OSS projects.
#
import os

import sys
from pathlib import Path

Expand All @@ -30,8 +30,7 @@
SECRET_KEY = env.str("SECRET_KEY")

ALLOWED_HOSTS = env.list(
"ALLOWED_HOSTS",
default=[".localhost", "127.0.0.1", "[::1]", "host.docker.internal"],
"ALLOWED_HOSTS", default=[".localhost", "127.0.0.1", "[::1]", "host.docker.internal"]
)

CSRF_TRUSTED_ORIGINS = env.list("CSRF_TRUSTED_ORIGINS", default=[])
Expand Down