-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
236 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 && \ | ||
|
@@ -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 | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.