Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build as container #426

Merged
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
34 changes: 34 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "roundware",
"dockerComposeFile": "docker-compose.yml",
"service": "roundware-dev",
"remoteUser": "root",
"runServices": ["roundware-db"],
"shutdownAction": "stopCompose",
"containerEnv": {
"DJANGO_SETTINGS_MODULE": "roundware.settings.testing",
"MANAGE_PY_PATH": "/code/roundware/manage.py"
},
"workspaceFolder": "/code",
"postCreateCommand": ["./.devcontainer/postCreate.sh"],
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-python.debugpy",
// "Pachwenko.django-test-runner"
],
"settings": {
"python.terminal.activateEnvInCurrentTerminal": true,
"python.defaultInterpreterPath": "/pythonenv/roundware-venv/bin/python",
"python.experiments.optInto": ["pythonTestAdapter"],
"python.testing.unittestEnabled": true,
"python.testing.pytestEnabled": false,
"python.testing.unittestArgs": [
"-p", "*test*.py"
],
// "python.djangoTestRunner.manageProgram": "python3 -m roundware.manage test",
}
}
}
}
13 changes: 7 additions & 6 deletions docker-compose.yml → .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3"
services:
roundware-db:
image: postgis/postgis
Expand All @@ -8,20 +7,22 @@ services:
POSTGRES_PASSWORD: round
ports:
- "5432"
roundware:
build: "."
image: roundware:latest

roundware-dev:
build:
context: ..
image: roundware-dev:latest
ports:
- "8888:8888"
command: python3 roundware/manage.py runserver 0.0.0.0:8888
command: python3 -m roundware.manage runserver 0.0.0.0:8888
environment:
ROUNDWARE_DEBUG: "true"
ROUNDWARE_DB_HOST: "roundware-db"
ROUNDWARE_DB_NAME: "round"
volumes:
- logs:/roundware/logs
- ..:/code
depends_on:
- roundware-db

volumes:
logs:
17 changes: 17 additions & 0 deletions .devcontainer/postCreate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

# install git in our devcontainer
apt-get update -y
apt-get install -y git
apt-get clean
rm -rf /var/lib/apt/lists/*

pip install -e .[dev,test]

# migrate the database
python -m roundware.manage migrate

# load fixture data
python -m roundware.manage loaddata default_auth.json
python -m roundware.manage loaddata sample_project.json

13 changes: 6 additions & 7 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ on:
jobs:
test:
container:
image: ubuntu:20.04
image: ubuntu:24.04

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.8]
python-version: [3.8, 3.9, 3.10, 3.11, 3.12]
services:
# Label used to access the service container
postgres:
Expand All @@ -39,12 +39,11 @@ jobs:
run: |
apt-get update
DEBIAN_FRONTEND=noninteractive xargs -a requirements.apt apt-get install -y --fix-missing
python3 --version
python3 -m pip install --upgrade pip setuptools
python3 -m pip install -r requirements/common.txt
python3 -m pip install -r requirements/dev.txt
python3 -m venv .venv
.venv/bin/python -m pip install --upgrade pip setuptools
.venv/bin/python -m pip install .[test]
echo "PYTHONPATH=$GITHUB_WORKSPACE:$PYTHONPATH" >> $GITHUB_ENV

echo PATH=${GITHUB_WORKSPACE}/.venv/bin:$PATH >> $GITHUB_ENV
- name: Run Tests
env:
ROUNDWARE_DB_USER: round
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ static
local_settings.py
.coverage
.idea/*

roundware.egg-info/**/*
.DS_Store
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ before_script:
- sudo mkdir /var/www
- sudo chmod 777 /var/www
- export PYTHONPATH=.:/usr/lib/python2.7/dist-packages/
script: python roundware/manage.py test --settings=roundware.settings.testing
script: python src/roundware/manage.py test --settings=roundware.settings.testing
40 changes: 25 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
FROM ubuntu:20.04 as roundware
FROM ubuntu:24.04
RUN mkdir /code
ENV PATH=/code:$PATH
ENV PYTHONPATH=/code
WORKDIR /code
RUN apt-get update

WORKDIR /code
ADD requirements.apt .
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive xargs -a requirements.apt apt-get install -y --fix-missing
RUN python3 -m pip install pip setuptools --upgrade
RUN which python3 && python3 --version
ADD requirements ./requirements
ADD requirements.txt .
ADD scripts ./scripts
ADD roundware ./roundware
RUN python3 -m pip install -r requirements.txt
RUN python3 -m pip install -r requirements/dev.txt
RUN python3 roundware/manage.py collectstatic
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y && \
xargs -a requirements.apt apt-get install -y --fix-missing && \
apt-get upgrade -y gdal-bin \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

ENV VIRTUAL_ENV=/pythonenv/roundware-venv
RUN mkdir /pythonenv/
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

RUN python3 -m pip install pip setuptools --upgrade && \
which python3 \
&& python3 --version

ADD pyproject.toml .
ADD scripts/ ./scripts
ADD roundware/ ./roundware

RUN python3 -m pip install .
RUN python3 -m roundware.manage collectstatic

ADD .coveragerc .
ADD .coveragerc .
24 changes: 4 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Overview

Roundware is a client-server system. The server runs using Apache HTTP Server
and mod_wsgi on Ubuntu Linux 20.04 LTS Focal Fossa and clients are available
and mod_wsgi on Ubuntu Linux 24.04 LTS Noble Numbat and clients are available
for [iOS](https://github.com/roundware/roundware-ios-framework-v2) and
[HTML5 browsers](https://gitlab.com/probabble/roundware-web-template)
(mobile and desktop). There is an old Android client as well, but it is not
Expand Down Expand Up @@ -40,28 +40,12 @@ settings in `/var/www/roundware/source/roundware/settings/common.py` can be
overridden there. Do not modify any file within the `/var/www/roundware/source`
directory unless you intend to maintain your own fork of Roundware Server.

## Vagrant
## Local Development Environment

A VagrantFile is included for local development and testing with
[Vagrant](http://www.vagrantup.com/) and [VirtualBox](https://www.virtualbox.org/).
Usage:
Roundware is now containerized for local development using devcontainers. We have not yet containerized for production, though that is on the roadmap. We have optimized for VSCode, but any IDE that integrates devcontainers should work.

user@local-machine:~ $ git clone https://github.com/roundware/roundware-server.git
user@local-machine:~ $ cd roundware-server
user@local-machine:~/roundware-server $ vagrant up
user@local-machine:~/roundware-server $ vagrant ssh
(roundware)vagrant@roundware-server:~$ cd roundware-server/scripts
(roundware)vagrant@roundware-server:~$ ./runserver.sh
[Dev Containers](https://containers.dev/ "Dev Containers")

Notes:

* The installation process uses the default *vagrant* user as project owner.
* The install script relies on the Vagrant default file share of
host:~/roundware-server to vm:/vagrant for installation and development.
* There are multiple port forwards from the host to the VM:
* VM:80->host:8080 for Apache hosting the demo "live" environment available at http://127.0.0.1:8080/
* VM:8888->host:8888 for the manage.py runserver development webserver available at http://127.0.0.1:8888/
* Edit the development environment code on your local machine, then refresh to see the changes reflected in the virtual machine.

## Code Upgrades

Expand Down
30 changes: 0 additions & 30 deletions Vagrantfile

This file was deleted.

95 changes: 95 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# pyproject.toml for installing instrument-data-collector
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "roundware"
description = "Roundware Server"
license = {text = "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)"}
dynamic = ['version']
authors = [
{"name" = "Halsey Burgund", "email" = "[email protected]"},
{"name" = "Mike MacHenry"},
{"name" = "Ben McAllister"},
{"name" = "Jule Slootbeek"},
{"name" = "Bryan Wilson"},
{"name" = "Brad Erickson", "email" = "[email protected]" },
{"name" = "Evan Babb", "email" = "[email protected]"},
]

maintainers = [
{"name" = "Halsey Burgund", "email" = "[email protected]"},
{"name" = "Evan Babb", "email" = "[email protected]"},
]

requires-python = ">=3.11"

dependencies = [
"Django==3.0",
# Creates REST APIs
"djangorestframework",
# locks down access to api endpoints
"django-dry-rest-permissions",
# Used for DRF filtering
"django-filter<2.3",
# Used in roundware/rw/admin.py, roundware/rw/forms.py, roundware/rw/views, and more.
"django-guardian==2.2.0",
# Used by roundware/api1/commands.py
"psutil==3.4.2",
# Used by roundware/rw/fields.py
# django-validated-file==2.0.1
"python-magic==0.4.8",
# Used in roundware/rw/views.py
"django-braces==1.14.0",
# Loaded in roundware/urls.py
# django-adminplus==0.2.1
# Used in roundware/rw/forms.py
"django-crispy-forms==1.9.1",
# Used in roundware/rw/widgets.py
"django-floppyforms==1.9.0",
# Used in roundware/rw/views.py:
"django-extra-views==0.13.0",
# Used in roundware/rw/fields.py and roundware/rw/widgets.py
"django-sortedm2m==3.1.1",
# Required for RDF Date parsing
"python-dateutil==2.2",
# Used in roundwared/icecast2.py
"requests<2.5",
# Used in admin, including Batch Tag Add
"django-formset-js==0.4.0",
# database adapter for PostgreSQL
"psycopg2",
# geographic distance calculator utilities
"geopy",
# cors support to remove php layer
"django-cors-headers==3.3.0",
# fiona is a useful tool for processing geographic files (ETL)
"fiona",
# geographic extensions for djangorestframework-gis
"djangorestframework-gis<=0.16",
# leaflet map utilities for django admin
"django-leaflet",
# Bootstrap admin theme for Django 1.9
# https://github.com/roundware/django-admin-bootstrapped/zipball/3.0.0
# audio conversions
"ffmpeg-python==0.2.0"
]

[project.optional-dependencies]
dev = [
"ipython",
]
test = [
"coverage",
"webtest",
"django-webtest",
"model_bakery",
"mock",
]

[tool.setuptools.dynamic]
version = { attr = "roundware.__version__"}

[tool.setuptools.packages.find]
where = ["."]
1 change: 1 addition & 0 deletions requirements.apt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ pacpl
python3
python3-dev
python3-pip
python3-venv
2 changes: 1 addition & 1 deletion requirements/common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ django-floppyforms==1.9.0
# Used in roundware/rw/views.py:
django-extra-views==0.13.0
# Used in roundware/rw/fields.py and roundware/rw/widgets.py
django-sortedm2m==0.8.1
django-sortedm2m==3.1.1
# Required for RDF Date parsing
python-dateutil==2.2
# Used in roundwared/icecast2.py
Expand Down
1 change: 1 addition & 0 deletions roundware/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.4.0'
6 changes: 3 additions & 3 deletions roundware/rw/migrations/0037_asset_file_and_loc_caption.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import django.core.files.storage
from django.db import migrations
import rw.fields
import roundware.rw.fields


class Migration(migrations.Migration):
Expand All @@ -17,11 +17,11 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='asset',
name='file',
field=rw.fields.ValidatedFileField(help_text='Upload file', storage=django.core.files.storage.FileSystemStorage(base_url='/rwmedia/', location='/var/www/roundware/rwmedia/'), upload_to='.'),
field=roundware.rw.fields.ValidatedFileField(help_text='Upload file', storage=django.core.files.storage.FileSystemStorage(base_url='/rwmedia/', location='/var/www/roundware/rwmedia/'), upload_to='.'),
),
migrations.AlterField(
model_name='asset',
name='loc_caption',
field=rw.fields.ValidatedFileField(help_text='Upload captions', null=True, storage=django.core.files.storage.FileSystemStorage(base_url='/rwmedia/', location='/var/www/roundware/rwmedia/'), upload_to='.'),
field=roundware.rw.fields.ValidatedFileField(help_text='Upload captions', null=True, storage=django.core.files.storage.FileSystemStorage(base_url='/rwmedia/', location='/var/www/roundware/rwmedia/'), upload_to='.'),
),
]
Loading
Loading