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
18 changes: 18 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"host": "localhost",
"port": 5678,
"pathMappings": [
{
"localRoot": "${workspaceFolder}/rcamp",
"remoteRoot": "/opt/rcamp"
}
]
}
]
}
99 changes: 54 additions & 45 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,77 +1,86 @@
FROM quay.io/rockylinux/rockylinux:8
LABEL maintainer="Adam W Zheng <wazh7587@colorado.edu>"

# Define s6 overlay process supervisor version
#ARG S6_OVERLAY_VERSION=3.1.5.0
# Use Python 3.11 as the base image
FROM python:3.11-slim

# Define gosu version
ARG GOSU_VERSION=1.16

# Install dependencies
RUN dnf -y install 'dnf-command(config-manager)' \
&& dnf config-manager --set-enabled powertools \
&& dnf -y install epel-release \
&& dnf -y groupinstall "Development Tools" \
&& dnf -y install xz dpkg which sssd pam_radius sqlite pam-devel openssl-devel python3-devel openldap-devel mysql-devel pcre-devel
# Install system dependencies
RUN apt-get update && apt-get install -y \
gnupg2 \
xz-utils \
dpkg \
which \
sssd \
libpam0g-dev \
libsqlite3-dev \
libssl-dev \
python3-dev \
libldap2-dev \
default-libmysqlclient-dev \
curl \
lsb-release \
ca-certificates \
build-essential \
libssl-dev \
libffi-dev \
libpq-dev \
libmariadb-dev \
libmariadb-dev-compat \
default-libmysqlclient-dev \
libldap2-dev \
libsasl2-dev \
pkg-config \
python3-dev \
python3-pip \
python3-venv \
sqlite3 \
git \
&& rm -rf /var/lib/apt/lists/*

# Install gosu to drop user and chown shared volumes at runtime
ADD ["https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-amd64", "/usr/bin/gosu"]
ADD ["https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-amd64.asc", "/tmp/gosu.asc"]
RUN gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
&& gpg --batch --verify /tmp/gosu.asc /usr/bin/gosu
RUN chmod +x /usr/bin/gosu \
&& gosu nobody true

# Cleanup
RUN dnf -y update && dnf clean all && rm -rf /var/cache/dnf && > /var/log/dnf.log

# Add s6-overlay process supervisor
#ADD ["https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz", "/tmp"]
#RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz
#ADD ["https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz", "/tmp"]
#RUN tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz
RUN curl -fsSL https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-amd64 -o /usr/bin/gosu \
&& chmod +x /usr/bin/gosu \
&& gosu nobody true

# Copy s6-supervisor source definition directory into container
#COPY ["etc/s6-overlay/", "/etc/s6-overlay/"]

# Set Workdir
# Set working directory
WORKDIR /opt/rcamp

# Add requirements
# Add requirements and other necessary files
ADD ["requirements.txt", "/opt/requirements.txt"]

# Add uwsgi conf
ADD ["uwsgi.ini", "/opt/uwsgi.ini"]

# Add codebase to container
ADD ["rcamp", "/opt/rcamp"]

# From old dockerfile
# Set up virtual environment
WORKDIR /opt
ENV VIRTUAL_ENV=/opt/rcamp_venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

# Install the dependencies from requirements.txt
COPY requirements.txt /opt/
RUN pip install --upgrade pip && \
pip install wheel && \
pip install -r requirements.txt

RUN git clone -b python3 https://github.com/ResearchComputing/django-ldapdb-test-env
WORKDIR /opt/django-ldapdb-test-env
RUN python3 setup.py install
# Clone and install the django-ldapdb-test-env repository
WORKDIR /opt/rcamp

#Port Metadata
# Cleanup
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Expose necessary ports
EXPOSE 80/tcp
EXPOSE 443/tcp

#Simple Healthcheck
# Simple Healthcheck
HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 CMD curl http://localhost:8000/ || exit 1

# s6-overlay entrypoint
#ENTRYPOINT ["/init"]

# Copy entrypoint script
COPY ["docker-entrypoint.sh", "/usr/local/bin/"]
ENTRYPOINT ["sh","/usr/local/bin/docker-entrypoint.sh"]

# Set entrypoint
ENTRYPOINT ["sh", "/usr/local/bin/docker-entrypoint.sh"]

# Default command to start the application
CMD ["/opt/rcamp_venv/bin/uwsgi", "/opt/uwsgi.ini"]

132 changes: 129 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# RCAMP
Research Computing Administrative &amp; Management Portal

## Overview and App Structure
# Table of Contents
1. [Overview](#overview)
2. [Installation](#installation)
3. [Tests](#tests)
4. [API](#api)

## Overview

**accounts** - The accounts app contains all code for the creation, review, and approval of account requests. Also contained in this app is all code necessary for managing users and groups.

Expand All @@ -15,7 +21,7 @@ Research Computing Administrative &amp; Management Portal

**rcamp** - The rcamp directory contains site code and, most importantly, settings.

## Setting up your dev environment
## Installation
You will need Docker 18.03+ and Compose 1.21+ before you begin. Documentation for Docker can be found here: https://docs.docker.com/install/.

Start by cloning RCAMP.
Expand Down Expand Up @@ -47,9 +53,129 @@ $ docker-compose run --rm --entrypoint "python3" rcamp-uwsgi manage.py createsup
```
The name, password, and email needed by the createsuperuser script can be whatever you like. You should now be able to view the webpage at localhost:8000.

## Writing and Running Tests
## Tests
Documentation on use of the RCAMP test framework can be found in the RCAMP Wiki [Test Framework page](https://github.com/ResearchComputing/RCAMP/wiki/Test-Framework).

```
$ docker-compose run --rm --entrypoint "python3" rcamp-uwsgi manage.py test
```

## API

If your user has superuser permissions, the endpoints can be used for queries. Here are examples of hitting the account requests endpoint

```bash
$ curl -u <username>:<password> "http://rcamp2.rc.int.colorado.edu/api/accountrequests/?min_approve_date=2025-03-15&max_approve_date=2025-03-16"
```
```json
[
{
"username": "rmaccuser23",
"first_name": "rmacc",
"last_name": "user",
"email": "rmacc23@user.com",
"organization": "xsede",
"discipline": "Visual & Performing Arts",
"course_number": null,
"sponsor_email": null,
"resources_requested": null,
"status": "a",
"approved_on": "2025-03-15T18:14:14Z",
"request_date": "2025-03-15T18:14:14Z",
"notes": ""
}
]
```

If I want to request all account requests on 2025-03-14
```bash
$ curl -u <user>:<pass> "http://rcamp2.rc.int.colorado.edu/api/accountrequests/?min_approve_date=2025-03-14&max_approve_date=2025-03-15"
```
```json
[
{
"username": "rmaccuser14",
"first_name": "rmacc",
"last_name": "user",
"email": "rmaccuser14@cool.com",
"organization": "xsede",
"discipline": "Hum",
"course_number": null,
"sponsor_email": null,
"resources_requested": null,
"status": "a",
"approved_on": "2025-03-14T11:13:15Z",
"request_date": "2025-03-14T11:13:15Z",
"notes": ""
},
{
"username": "dahdahdah",
"first_name": "rmacc",
"last_name": "user",
"email": "rmacc255@user.com",
"organization": "xsede",
"discipline": "Law",
"course_number": null,
"sponsor_email": null,
"resources_requested": null,
"status": "a",
"approved_on": "2025-03-14T12:27:11Z",
"request_date": "2025-03-14T12:27:19Z",
"notes": ""
},
{
"username": "rmaccuser",
"first_name": "rmacc",
"last_name": "user",
"email": "rmacc@Colorado.EDU",
"organization": "ucb",
"discipline": "Physical Sciences",
"course_number": null,
"sponsor_email": null,
"resources_requested": null,
"status": "a",
"approved_on": "2025-03-14T12:29:28Z",
"request_date": "2025-03-14T12:29:29Z",
"notes": null
}
]
```

If you interested in a specific discipline you can use a substring to get results:
```bash
curl -u <user>:<pass> "http://rcamp2.rc.int.colorado.edu/api/accountrequests/?discipline=Visual"
```
```json
[
{
"username": "rmaccuser23",
"first_name": "rmacc",
"last_name": "user",
"email": "rmacc23@user.com",
"organization": "xsede",
"discipline": "Visual & Performing Arts",
"course_number": null,
"sponsor_email": null,
"resources_requested": null,
"status": "a",
"approved_on": "2025-03-15T18:14:14Z",
"request_date": "2025-03-15T18:14:14Z",
"notes": ""
},
{
"username": "rmacc-user67",
"first_name": "rmacc67",
"last_name": "user67",
"email": "rmacc67@user.com",
"organization": "xsede",
"discipline": "Visual & Performing Arts",
"course_number": null,
"sponsor_email": null,
"resources_requested": null,
"status": "a",
"approved_on": "2025-03-16T16:36:00Z",
"request_date": "2025-03-16T16:36:00Z",
"notes": ""
}
]
```
2 changes: 2 additions & 0 deletions cmds
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docker-compose run --rm --entrypoint "python3" rcamp-uwsgi manage.py migrate
docker-compose run --rm --entrypoint "python3" rcamp-uwsgi manage.py createsuperuser
58 changes: 44 additions & 14 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,70 @@
version: "3.6"

services:
rcamp-uwsgi:
image: rcamp-uwsgi2
build:
context: .
container_name: rcamp-uwsgi
command: ["python3", "manage.py", "runserver", "0.0.0.0:8000"]
hostname: ${HOSTNAME}
#command: ["python3", "manage.py", "runserver", "0.0.0.0:8000"]
env_file:
- dev-environment.env
- .env
environment:
- UWSGI_UID=${UWSGI_UID}
- UWSGI_GID=${UWSGI_GID}
volumes:
- ./rcamp:/opt/rcamp
- ./ldapdb:/opt/ldapdb
- static-content:/opt/static
- media-uploads:/opt/media
- rcamp-logs:/opt/logs
ports:
- "80:8000"
- /var/lib/sss/pipes:/var/lib/sss/pipes:rw
- ./rcamp-pam/nsswitch.conf:/etc/nsswitch.conf
- ./rcamp-pam/pam.d:/etc/pam.d
- ./rcamp-pam/raddb:/etc/raddb
- ./static-content:/opt/static
- ${MEDIA_DIR}:/opt/media
- ./rcamp-logs:/opt/logs
# ports:
# - "80:8000"
# - "443:443"
#- "5678:5678" # Debugger port
depends_on:
- database
- ldap
database:
condition: service_healthy
logging:
driver: syslog

database:
image: mysql:5.7
image: mysql:8.4
container_name: database
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_DATABASE=rcamp1712
volumes:
- database:/var/lib/mysql
healthcheck:
test: ["CMD-SHELL", "mysqladmin ping -h localhost -u root -ppassword"]
interval: 10s
timeout: 5s
retries: 5

ldap:
image: researchcomputing/rc-test-ldap
container_name: ldap
nginx:
hostname: ${HOSTNAME}
image: nginx:1.20.0
container_name: nginx
volumes:
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
- ./nginx/uwsgi_params:/etc/nginx/uwsgi_params:ro
- ${SSL_CERT}:/etc/nginx/certs/rcamp.crt:ro
- ${SSL_KEY}:/etc/nginx/certs/rcamp.key:ro
- ${MEDIA_DIR}:/var/www/media:ro
- ./static-content:/var/www/static:ro
- ./nginx-logs:/var/logs/nginx
ports:
- "80:80"
- "443:443"
logging:
driver: syslog
depends_on:
- rcamp-uwsgi

volumes:
static-content:
Expand Down
Loading
Loading