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
3 changes: 2 additions & 1 deletion backup/volumes_list
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ singularity_email-journal
singularity_orbit-db
singularity_ssl-certs
singularity_submatrix-data
singularity_grades-db
singularity_submissions-db
singularity_denis-db
'
50 changes: 0 additions & 50 deletions chronus/Containerfile

This file was deleted.

20 changes: 0 additions & 20 deletions chronus/db.py

This file was deleted.

38 changes: 19 additions & 19 deletions container-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ services:
- orbit_singularity_git_dir=./.git
- orbit_docs_source=./docs
- orbit_repos_source=./cgit_repos
- denis_source=./denis
- mailman_source=./mailman
target: orbit
args:
orbit_version_info: "singularity ${SINGULARITY_VERSION} ${SINGULARITY_DEPLOYMENT_STATUS} https://github.com/underground-software/singularity"
Expand All @@ -50,8 +50,8 @@ services:
target: /var/lib/orbit
read_only: false
- type: volume
source: grades-db
target: /var/lib/denis
source: submissions-db
target: /var/lib/mailman
read_only: true
networks:
- orbit
Expand Down Expand Up @@ -114,9 +114,9 @@ services:
networks:
- submatrix
- orbit
denis:
mailman:
build:
context: denis
context: mailman
dockerfile: Containerfile
additional_contexts:
- watcher_source=./watcher
Expand All @@ -130,28 +130,28 @@ services:
target: /var/lib/email/logs
read_only: true
- type: volume
source: grades-db
target: /var/lib/denis
source: submissions-db
target: /var/lib/mailman
read_only: false
depends_on:
- smtp
networks:
- denis
chronus:
- mailman
denis:
build:
context: chronus
context: denis
dockerfile: Containerfile
additional_contexts:
- run_at_source=./run-at
- pop_source=./pop
- denis_source=./denis
- mailman_source=./mailman
- orbit_source=./orbit
args:
CHRONUS_HOSTNAME: ${SINGULARITY_HOSTNAME}
volumes:
- type: volume
source: chronus-db
target: /var/lib/chronus
source: denis-db
target: /var/lib/denis
read_only: false
- type: volume
source: email-journal
Expand All @@ -162,25 +162,25 @@ services:
target: /var/lib/orbit
read_only: true
- type: volume
source: grades-db
target: /var/lib/denis
source: submissions-db
target: /var/lib/mailman
read_only: true
networks:
- chronus
- denis
- smtp
networks:
orbit:
smtp:
pop:
submatrix:
mailman:
denis:
chronus:
volumes:
ssl-certs:
email-mail:
email-logs:
email-journal:
orbit-db:
grades-db:
submissions-db:
submatrix-data:
chronus-db:
denis-db:
35 changes: 25 additions & 10 deletions denis/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,49 @@ FROM alpine:3.19 AS build
RUN apk add \
clang \
make \
envsubst \
;

COPY --from=watcher_source . /watcher
COPY --from=run_at_source . /run-at

RUN make -C /watcher CC='clang -static'
RUN make -C /run-at CC='clang -static'

COPY --from=pop_source . /pop

RUN make -C /pop CC='clang -static' restrict_access

WORKDIR /usr/local/share/denis
COPY . .

ARG CHRONUS_HOSTNAME
RUN test -n "$CHRONUS_HOSTNAME " || (echo 'CHRONUS_HOSTNAME is not set' && false) && \
mv config.py config.py.template && \
envsubst '$CHRONUS_HOSTNAME' < config.py.template > config.py && \
rm config.py.template \
;

FROM alpine:3.19 AS denis

RUN apk add \
py3-peewee \
py3-gitpython \
py3-curl \
;


WORKDIR /usr/local/share/denis

COPY . .
COPY --from=build /usr/local/share/denis .
COPY --from=mailman_source . ./mailman
COPY --from=orbit_source . ./orbit

RUN mkdir -p /var/lib/denis/ && \
RUN mkdir -p /var/lib/denis && \
./db.py \
:

RUN chown -R 100:100 /var/lib/denis

COPY --from=build /watcher/watcher /usr/local/bin/watcher

VOLUME /var/lib/email/
COPY --from=build /run-at/run-at /usr/local/bin/run-at
COPY --from=build /pop/restrict_access /usr/local/bin/restrict_access

USER 100:100

ENTRYPOINT ["/usr/local/bin/watcher", "/var/lib/email/logs", "submit.py"]
ENTRYPOINT ["/usr/local/share/denis/start.py"]
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion chronus/configure.sh → denis/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ set -e

COMPOSE=${COMPOSE:-podman-compose}

${COMPOSE} exec chronus ./configure.py "$@"
${COMPOSE} exec denis ./configure.py "$@"

13 changes: 5 additions & 8 deletions denis/db.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env python3

import peewee

DB = peewee.SqliteDatabase("/var/lib/denis/grades.db")
DB = peewee.SqliteDatabase("/var/lib/denis/assignments.db")


class BaseModel(peewee.Model):
Expand All @@ -11,12 +10,10 @@ class Meta:
strict_tables = True


class Submission(BaseModel):
submission_id = peewee.TextField(unique=True)
assignment = peewee.TextField()
timestamp = peewee.IntegerField()
user = peewee.TextField()
status = peewee.TextField()
class Assignment(BaseModel):
name = peewee.TextField(unique=True)
initial_due_date = peewee.IntegerField()
final_due_date = peewee.IntegerField()


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion chronus/final.py → denis/final.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
# Block all students from seeing emails sent until
# we allow again after initial sub deadline
for user in orbit.db.User.select():
os.system(f'restrict_access /var/lib/email/journal/journal -d {user.username}')
os.system(f'restrict_access /var/lib/email/journal/journal -d {user.username}') # NOQA: 501
18 changes: 9 additions & 9 deletions chronus/initial.py → denis/initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
import sys

import config
import denis.db
import mailman.db
import orbit.db


def generate_peer_review_email(assignment, review_table):
return f'''\
Subject: Peer review assignments for {assignment}
Expand Down Expand Up @@ -103,14 +104,13 @@ def generate_peer_review_email(assignment, review_table):
- An attempt to apply the cover letter will require a `git am --abort`
'''


# this is passed from start.py via run-at
assignment = sys.argv[1]

students_who_submitted = [user.username for user in orbit.db.User.select()
if denis.db.Submission.get_or_none((denis.db.Submission.user
== user.username) &
(denis.db.Submission.assignment
== assignment)) is not None]
if mailman.db.Submission.get_or_none((mailman.db.Submission.user == user.username) & # NOQA: E501
(mailman.db.Submission.assignment == assignment)) is not None] # NOQA: E501

# let them see emails that have been sent since last final due date
for student in students_who_submitted:
Expand All @@ -131,9 +131,9 @@ def generate_peer_review_email(assignment, review_table):
# is the situation where there are fewer than 3 students total and it is
# impossible to have any triplets. In that case we can form two pairs,
# one singleton, or the empty list which is why we have min(len, 3)
reviews = [[students_who_submitted[i+j] for j in
range(-min(len(students_who_submitted), 3), 0)]
for i in range(len(students_who_submitted))]
reviews = [[students_who_submitted[i+j]
for j in range(-min(len(students_who_submitted), 3), 0)]
for i in range(len(students_who_submitted))]

# To make it easier for the student to find their row, we can sort the
# list. This will alphabetize based on the first column (and only the
Expand All @@ -152,7 +152,7 @@ def generate_peer_review_email(assignment, review_table):
email_contents = generate_peer_review_email(assignment, review_table)

client = pycurl.Curl()
client.setopt(client.URL, f'smtp://smtp:1465')
client.setopt(client.URL, 'smtp://smtp:1465')

# Client must log in, so the server knows their username
# but the password is not verified by the upstream server,
Expand Down
1 change: 1 addition & 0 deletions chronus/start.py → denis/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import db


def spawn_waiter(timestamp, name, script):
return subprocess.Popen(['/usr/local/bin/run-at', timestamp, script, name])

Expand Down
35 changes: 35 additions & 0 deletions mailman/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM alpine:3.19 AS build
RUN apk add \
clang \
make \
;

COPY --from=watcher_source . /watcher

RUN make -C /watcher CC='clang -static'

FROM alpine:3.19 AS mailman

RUN apk add \
py3-peewee \
py3-gitpython \
;


WORKDIR /usr/local/share/mailman

COPY . .

RUN mkdir -p /var/lib/mailman/ && \
./db.py \
:

RUN chown -R 100:100 /var/lib/mailman

COPY --from=build /watcher/watcher /usr/local/bin/watcher

VOLUME /var/lib/email/

USER 100:100

ENTRYPOINT ["/usr/local/bin/watcher", "/var/lib/email/logs", "submit.py"]
Loading