Skip to content
Open
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
2 changes: 2 additions & 0 deletions devops/docker/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ COMPOSE_PROJECT_NAME=miqa
GIRDER_ADMIN_NAME=
GIRDER_ADMIN_PASS=
GIRDER_API_ROOT=/api/v1
GIRDER_CREATE_ASSETSTORE=true
GIRDER_CREATE_COLLECTION=true
GIRDER_STATIC_PUBLIC_PATH=/static
GIRDER_SMTP_RELAY=smtp-relay
GIRDER_SMTP_PORT=587
Expand Down
48 changes: 37 additions & 11 deletions devops/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
FROM node:10.24.0-buster
FROM node:10.24.1-buster

EXPOSE 8080

RUN apt-get update && apt-get install -qy \
# Debian 10/Buster is archived now.
RUN set -eux; \
printf '%s\n' \
'deb http://archive.debian.org/debian buster main contrib non-free' \
'deb http://archive.debian.org/debian-security buster/updates main contrib non-free' \
'deb http://archive.debian.org/debian buster-updates main contrib non-free' \
> /etc/apt/sources.list; \
printf 'Acquire::Check-Valid-Until "false";\n' > /etc/apt/apt.conf.d/99archive; \
apt-get update; \
apt-get install -qy --no-install-recommends \
build-essential \
gcc \
git \
libffi-dev \
libpython3-dev \
libsasl2-dev \
python3-dev \
python3-pip \
git \
libsasl2-dev && \
apt-get clean && rm -rf /var/lib/apt/lists/*
python3-setuptools \
python3-wheel; \
apt-get clean; \
rm -rf /var/lib/apt/lists/*

# See http://click.pocoo.org/5/python3/#python-3-surrogate-handling for more detail on
# why this is necessary.
Expand All @@ -25,30 +40,41 @@ api_root = \"${GIRDER_API_ROOT}\"\n\
static_public_path = \"${GIRDER_STATIC_PUBLIC_PATH}\"\n"\
>> /etc/girder.cfg

# patch install
RUN python3 -m pip install --no-cache-dir --upgrade "pip<24" "setuptools<60" wheel
RUN python3 -m pip install --no-cache-dir \
setuptools_scm==7.1.0 \
bcrypt==3.1.0 \
"pymongo>=3.6,<4"

# Install girder
RUN mkdir /miqa
COPY server/ /miqa/server/
RUN pip3 install /miqa/server
RUN python3 -m pip install --no-cache-dir /miqa/server
RUN girder build

# Install miqa
COPY client /miqa/client
WORKDIR /miqa/client
RUN npm install \
&& npm run build \
RUN npm ci --no-audit --no-fund --verbose \
&& npm run build --verbose \
&& mv dist /usr/share/girder/static/miqa

# Add sample data
COPY sample_data /miqa/sample_data
RUN sed -i 's/~//g' /miqa/sample_data/sample.json

RUN git clone https://github.com/girder/girder.git girder_repo \
&& pip3 install ansible \
RUN git init girder_repo \
&& cd girder_repo \
&& git remote add origin https://github.com/girder/girder.git \
&& git fetch --depth 1 origin ceb7074aa20582c3716ea322cfd5755bf37f0cfb \
&& git checkout FETCH_HEAD \
&& python3 -m pip install --no-cache-dir "ansible~=2.7" \
&& ansible-galaxy install -p /girder_repo/devops/ansible/roles girder.girder
RUN pip3 install girder_client
COPY devops/docker/provision.yml /provision.yml
COPY devops/docker/inventory /etc/ansible/hosts
ENV ANSIBLE_LIBRARY=/girder_repo/devops/ansible/roles/girder.girder/library

COPY devops/docker/entrypoint.sh /entrypoint.sh
ENTRYPOINT ["bash", "/entrypoint.sh"]
ENTRYPOINT ["bash", "/entrypoint.sh"]
5 changes: 2 additions & 3 deletions devops/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "2"

services:
database:
Expand All @@ -25,11 +24,11 @@ services:
command:
[
"database:27017",
"admin_name=${GIRDER_ADMIN_NAME} admin_pass=${GIRDER_ADMIN_PASS} admin_email=${GIRDER_ADMIN_USER_EMAIL} smtp_server=${GIRDER_SMTP_RELAY} smtp_port=${GIRDER_SMTP_PORT} smtp_encryption=${GIRDER_SMTP_CRYPTO} smtp_username=${GIRDER_SMTP_USER} smtp_password=${GIRDER_SMTP_PASSWD} server_url_in_email=${SERVER_URL_IN_EMAIL} sender_address=${SENDER_ADDRESS} sample_data=${SAMPLE_DATA} session_timeout=${MIQA_SESSION_TIMEOUT}",
"admin_name=${GIRDER_ADMIN_NAME} admin_pass=${GIRDER_ADMIN_PASS} admin_email=${GIRDER_ADMIN_USER_EMAIL} smtp_server=${GIRDER_SMTP_RELAY} smtp_port=${GIRDER_SMTP_PORT} smtp_encryption=${GIRDER_SMTP_CRYPTO} smtp_username=${GIRDER_SMTP_USER} smtp_password=${GIRDER_SMTP_PASSWD} server_url_in_email=${SERVER_URL_IN_EMAIL} sender_address=${SENDER_ADDRESS} sample_data=${SAMPLE_DATA} session_timeout=${MIQA_SESSION_TIMEOUT} create_assetstore=${GIRDER_CREATE_ASSETSTORE:-true} create_collection=${GIRDER_CREATE_COLLECTION:-true}",
]

smtp-relay:
image: hongkongkiwi/postfix-smtp-relay:latest
image: boky/postfix:latest
links:
- web_server
environment:
Expand Down
16 changes: 12 additions & 4 deletions devops/docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Run provisioning in the background
ansible-playbook -v --extra-vars "$2" /provision.yml &
# start girder server
girder serve --host 0.0.0.0 --database mongodb://"$1"/girder
#!/bin/sh
set -e

girder serve --host 0.0.0.0 --database mongodb://"$1"/girder &
GIRDER_PID=$!

ansible-playbook -v --extra-vars "$2" /provision.yml

kill "$GIRDER_PID"
wait "$GIRDER_PID" || true

exec girder serve --host 0.0.0.0 --database mongodb://"$1"/girder
2 changes: 2 additions & 0 deletions devops/docker/provision.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
- "Collaborator"

- name: Ensure Default Assetstore
when: create_assetstore | default(true) | bool
girder:
host: "localhost"
port: "8080"
Expand All @@ -66,6 +67,7 @@
state: present

- name: Ensure Default Collection
when: create_collection | default(true) | bool
girder:
host: "localhost"
port: "8080"
Expand Down
37 changes: 37 additions & 0 deletions server/miqa_server/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import datetime
import smtplib
from girder import logger
from girder.utility import mail_utils
from girder import events, plugin
from girder.models.user import User
from girder.utility import server
Expand All @@ -22,4 +25,38 @@ def load(self, info):
info['apiRoot'].miqa_email = Email()
info['apiRoot'].miqa_setting = SettingResource()

_orig_init = smtplib.SMTP.__init__

def debug_smtp_init(self, *args, **kwargs):
_orig_init(self, *args, **kwargs)
self.set_debuglevel(1)

smtplib.SMTP.__init__ = debug_smtp_init

original_send = mail_utils._SMTPConnection.send
original_enter = mail_utils._SMTPConnection.__enter__

def debug_enter(self):
logger.info(
'SMTP debug: connecting host=%r port=%r encryption=%r username=%r',
self.host, self.port, self.encryption, self.username
)
return original_enter(self)

def debug_send(self, fromAddress, toAddresses, message):
logger.info(
'SMTP debug: sending from=%r to=%r message_len=%d',
fromAddress, toAddresses, len(message)
)
try:
result = original_send(self, fromAddress, toAddresses, message)
logger.info('SMTP debug: sendmail completed: %r', result)
return result
except Exception:
logger.exception('SMTP debug: sendmail failed')
raise

mail_utils._SMTPConnection.__enter__ = debug_enter
mail_utils._SMTPConnection.send = debug_send

server.getStaticRoot = lambda: 'static'
8 changes: 7 additions & 1 deletion server/miqa_server/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,15 @@ def sendEmail(self, message, params):
alternative.attach(MIMEText(''.join(
[('<p>%s</p>' % line) for line in body.splitlines()])+'<br />'+'<br />'.join(images_html), 'html'))

to = message.get('to', [])
cc = message.get('cc', [])
bcc = message.get('bcc', [])

print("MIQA EMAIL ROUTE HIT", msg['From'], list(set(to) | set(cc) | set(bcc)), flush=True)

events.daemon.trigger('_sendmail', info={
'message': msg,
'recipients': list(set(message['to']) | set(message['cc']) | set(message['bcc']))
'recipients': list(set(to) | set(cc) | set(bcc))
})


Expand Down
1 change: 1 addition & 0 deletions server/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from setuptools import setup, find_packages

requirements = [
'setuptools_scm==7.1.0',
'cryptography==3.2.1',
'girder==3.1.4',
'girder_jobs==3.1.4',
Expand Down