Skip to content

Commit

Permalink
updating to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronk committed Sep 26, 2024
1 parent 462d226 commit 3454a7d
Show file tree
Hide file tree
Showing 16 changed files with 236 additions and 263 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/docker-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build and Push Docker image

on:
release:
types: [published]

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Setup SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.FASIFX_SSH_KEY }}

- name: Checkout Repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.release.tag_name }}
submodules: 'true'
ssh-key: ${{ secrets.FASIFX_SSH_KEY }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and Push Docker image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: harvardinformatics/{{project_name}}:latest
target: prod

49 changes: 36 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
# syntax=docker/dockerfile:experimental
FROM python:3.10-bookworm
FROM python:3.10-bookworm as base

EXPOSE 80
RUN apt-get update -y && apt-get install -y \
RUN apt-get update -y && apt-get install -y psmisc \
nginx \
supervisor \
curl \
gnupg \
ca-certificates
imagemagick
RUN mkdir ~/.ssh && echo "Host git*\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config

RUN echo "daemon off;" >> /etc/nginx/nginx.conf
COPY etc/nginx.conf /etc/nginx/sites-available/default
COPY etc/supervisor.conf /etc/supervisor/conf.d/app.conf

RUN mkdir -p /etc/apt/keyrings && \
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \
| gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
Expand All @@ -26,23 +21,51 @@ RUN mkdir -p /etc/apt/keyrings && \
# Forcing install of these versions. Goes haywire otherwise
RUN npm install -g @vue/[email protected] @vue/[email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]

# Django REST backend
FROM base as drf

WORKDIR /app

COPY requirements.txt /app

RUN --mount=type=ssh pip install --upgrade pip && \
pip install gunicorn && \
RUN pip install --upgrade pip && \
pip install 'Django>4,<5' && \
pip install certifi --upgrade --force && \
pip install gunicorn=='21.2.0' && \
pip install -r requirements.txt

ADD . /app

ENV PYTHONPATH /app:/app/ifxreport:/app/djvocab:/app/ifxurls:/app/nanites.client:/app/ifxuser:/app/ifxauth:/app/ifxmail.client:/app/ifxrequest:/app/ifxec:/app/fiine.client:/app/ifxbilling
ENV PYTHONPATH /app:/app/djvocab:/app/ifxurls:/app/nanites.client:/app/ifxuser:/app/ifxauth:/app/ifxmail.client:/app/ifxrequest:/app/ifxec:/app/fiine.client:/app/ifxbilling:/app/ifxlog
ENV DJANGO_SETTINGS_MODULE {{project_name}}.settings

RUN mkdir -p /app/media/reports
RUN mkdir -p /app/media/uploads/tool_thumbs
RUN mkdir -p /app/media/uploads/tool_images
RUN mkdir -p /app/static

CMD ./wait-for-it.sh -t 120 {{project_name}}-db:3306 && \
./manage.py collectstatic --no-input && \
./manage.py makemigrations {{project_name}} && \
./manage.py migrate && \
./manage.py applyDevData && \
./manage.py runserver 0.0.0.0:80 --insecure

# Vue frontend
FROM base as ui

EXPOSE 8080
WORKDIR /app/frontend
CMD npm run-script serve

# Production
FROM drf as prod

RUN echo "daemon off;" >> /etc/nginx/nginx.conf
COPY etc/nginx.conf /etc/nginx/sites-available/default
COPY etc/supervisor.conf /etc/supervisor/conf.d/app.conf

RUN rm -rf /app/frontend/dist/* && rm -rf /static/*
RUN cd frontend && yarn cache clean && yarn add harvardinformatics/ifxvue#ajk_deploy --network-timeout 100000 && yarn --check-files && yarn build
RUN cd frontend && yarn cache clean && yarn add harvardinformatics/ifxvue#ajk_deploy --network-timeout 100000 && yarn --check-files && rm -f yarn.lock && (yarn build || yarn build)
RUN mkdir -p /app/frontend/dist/static && ./manage.py collectstatic --noinput
RUN cp -r /app/frontend/dist/* /static

Expand Down
25 changes: 0 additions & 25 deletions Dockerfile-drf

This file was deleted.

10 changes: 0 additions & 10 deletions Dockerfile-ui

This file was deleted.

49 changes: 21 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,64 +1,57 @@
# Minimal makefile for Sphinx documentation
#

PACKAGE_NAME = {{project_name}}
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXAPIDOC = sphinx-apidoc
SOURCEDIR = docs/src
BUILDDIR = docs/build

PRODIMAGE = registry.gitlab-int.rc.fas.harvard.edu/informatics/{{project_name}}:latest
PRODBUILDARGS = --ssh default
PRODIMAGE = harvardinformatics/{{project_name}}:latest
PRODBUILDARGS =

DRFIMAGE = {{project_name}}-drf
DRFBUILDARGS = --ssh default
DRFFILE = Dockerfile-drf

UIIMAGE = {{project_name}}-ui
UIBUILDARGS =
UIFILE = Dockerfile-ui
DEVDRFIMAGE = {{project_name}}-drf
DEVDRFBUILDARGS =
DEVDRFFILE = Dockerfile
DEVUIIMAGE = {{project_name}}-ui
DEVUIFILE = Dockerfile

DOCKERCOMPOSEFILE = docker-compose.yml
DOCKERCOMPOSEARGS =

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: test Makefile docs drf ui build clean test-ui test-drf
clean:
find . -name "*.pyc" -print0 | xargs -0 rm -f
.PHONY: help docs Makefile prod up down build

build: drf ui
ui:
docker build -t $(UIIMAGE) -f $(UIFILE) $(UIBUILDARGS) .
docker build -t $(DEVUIIMAGE) -f $(DEVUIFILE) . --target ui
drf:
docker build -t $(DRFIMAGE) -f $(DRFFILE) $(DRFBUILDARGS) .

docker build -t $(DEVDRFIMAGE) -f $(DEVDRFFILE) $(DEVDRFBUILDARGS) . --target drf
prod:
./set-version.sh
docker build --platform linux/amd64 -t $(PRODIMAGE) $(PRODBUILDARGS) . --no-cache
docker build --platform linux/amd64 -t $(PRODIMAGE) $(PRODBUILDARGS) . --target prod
docker push $(PRODIMAGE)
up: drf
docker compose -f $(DOCKERCOMPOSEFILE) $(DOCKERCOMPOSEARGS) up
down:
docker compose -f $(DOCKERCOMPOSEFILE) down
up-local: drf
up-local:
docker compose -f docker-compose-local.yml $(DOCKERCOMPOSEARGS) up
down-local:
docker compose -f docker-compose-local.yml down
run: drf
docker compose run $(DRFIMAGE) /bin/bash
test-drf: drf
docker compose run $(DRFIMAGE) ./manage.py test -v 2; docker compose down
test-ui: ui
docker volume rm {{project_name}}_{{project_name}}-data
docker compose run $(UIIMAGE) ../wait-for-it.sh -s -t 120 {{project_name}}-drf:80 -- npm run-script test:e2e; docker compose down
test: test-drf

test: drf
docker compose run {{project_name}}-drf ./wait-for-it.sh -t 60 {{project_name}}-db:3306 -- ./manage.py test -v 2; docker compose down

docs:
docker compose run $(DRFIMAGE) make html; docker compose down
docker compose run {{project_name}}-drf make html; docker compose down

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXAPIDOC) -e -M --force -o "$(SOURCEDIR)" {{project_name}}
@$(SPHINXAPIDOC) -e -M --force -o "$(SOURCEDIR)" {{project_name}} {{project_name}}/migrations*
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@vue/babel-preset-app": "^4.5.11",
"axios": "0.28.0",
"coa": "2.0.2",
"core-js": "3.25.2",
"core-js": "3.37.1",
"ifxvue": "harvardinformatics/ifxvue#ajk_deploy",
"lodash": "4.17.21",
"material-design-icons-iconfont": "6.1.0",
Expand All @@ -39,7 +39,7 @@
"@vue/compiler-sfc": "3.0.2",
"@vue/eslint-config-airbnb": "5.1.0",
"@babel/eslint-parser": "7.23.10",
"braces": "2.3.2",
"braces": "3.0.3",
"eslint": "7.32.0",
"eslint-import-resolver-webpack": "0.13.0",
"eslint-plugin-import": "2.22.1",
Expand Down
29 changes: 20 additions & 9 deletions frontend/src/API/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,32 @@ export const DJANGO_ADMIN_ROOT = `${ROOT_URL}djadmin/`
// URLs
export const MESSAGES = 'messages/'
export const MAILINGS = 'mailings/'
export const SEND_MAILING = 'send-mailing/'
export const SEND_IFXMAILING = 'send-mailing/'
export const MOCK_ERRORS = 'mock-errors/'
export const USERS = 'users/'
export const USER_FILES = 'user-files/'
export const SKINNY_USERS = 'skinny-users/'
export const SKINNY_ACCOUNTS = 'skinny-accounts/'
export const UPDATE_NANITES = 'update-nanites/'
export const NANITES = 'nanites/'
export const CONTACT_FILES = 'contact_files/'
export const GET_CONTACT_LIST = 'contacts/'
export const CONTACTS = 'contacts/'
export const ORGANIZATIONS = 'organizations/'
export const SKINNY_ORGANIZATIONS = 'get-org-list/'
export const ORGANIZATION_NAMES = 'get-org-names/'
export const UPDATE_USER_ACCOUNTS = 'billing/update-user-accounts/'
export const ACCOUNTS = 'accounts/'
export const GROUPS = 'groups/'
export const GET_USERS = 'users/'
export const UPDATE_USER = 'users/'
export const UPDATE_PERSON = 'users/update-person/'
export const GET_LOCATION_INFO = 'get-location-info/'
export const GET_NANITE_LOGIN = 'users/get-nanite-login/'
export const CONTACTABLES = 'get-contactables/'
export const SET_REQUEST_STATE = 'requests/set-request-state/'
export const UPDATE_REQUESTS = 'requests/'
export const GET_REQUEST_LIST = 'requests/get-request-list/'
export const UPDATE_ONBOARD_REQUESTS = 'onboard-requests/'
export const GET_VALID_PROCESSOR_STATES = 'requests/get-valid-processor-states/'
export const GET_CONTACT_LIST = 'contacts/get-contact-list/'
export const CONTACTS = 'contacts/'
export const ORGANIZATIONS = 'organizations/'
export const ORGANIZATION_NAMES = 'get-org-names/'
export const PRODUCT_USAGES = 'product-usages/'
export const CALCULATE_BILLING_MONTH = 'billing/calculate-billing-month/'
export const BILLING_RECORD_LIST = 'billing/get-billing-record-list/'
export const BILLING_RECORDS = 'billing-records/'
export const BILLING_RECORD_REVIEW_NOTIFICATION = 'billing/billing-record-review-notification/'
Loading

0 comments on commit 3454a7d

Please sign in to comment.