Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add build and push step to GH Actions #1083

Merged
merged 23 commits into from
Sep 21, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build image

on:
push:
branches:
- 'master'
tags:
- 'v*'
pull_request:
branches:
- 'master'

jobs:
build-and-push-docker-image:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/neuroscout/neuroscout

- name: Login to Github Packages
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build image and push to Docker Hub and GitHub Container Registry
uses: docker/build-push-action@v3
with:
context: ./neuroscout
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ For single sign on using Google, a [sign-in project](https://developers.google.c
## Initalizing backend
Build the containers and start services using the development configuration:

docker-compose build
docker-compose -f docker-compose.yml -f docker-compose.dev.yml build
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d

The server should now be running at http://localhost/
The server should now be running at http://localhost/

Next, initialize, migrate and upgrade the database migrations.
If you have a database file, load it using `pg_restore`. Otherwise, delete the migrations folder,
Expand All @@ -45,6 +45,20 @@ initalize the database and add a test user.
python manage.py db upgrade
python manage.py add_user useremail password

### Staging & production server

For the staging server, you can trigger a manual build as follows:

docker-compose -f docker-compose.yml -f docker-compose.build.yml build
docker-compose -f docker-compose.yml -f docker-compose.build.yml up -d

For the staging or production server, you can trigger pull a pre-built image from GHCR:
First set the variable `IMAGE_TAG` to the apprioriate image tag

docker-compose -f docker-compose.yml -f docker-compose.image.yml build
docker-compose -f docker-compose.yml -f docker-compose.image.yml up -d


## Setting up front end
The frontend dependencies are managed using `yarn`

Expand Down
4 changes: 4 additions & 0 deletions docker-compose.build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: "2"
services:
neuroscout:
build: ./neuroscout
1 change: 1 addition & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ services:
neuroscout:
command: /usr/local/bin/gunicorn -w 2 -b :8000 neuroscout.core:app --log-level debug --timeout 120 --reload
restart: "no"
build: ./neuroscout
ports:
- "4000:4000"
4 changes: 4 additions & 0 deletions docker-compose.image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: "2"
services:
neuroscout:
image: ghcr.io/neuroscout/neuroscout:${IMAGE_TAG}
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: "2"
services:
neuroscout:
image: neuroscout_neuroscout
restart: always
build: ./neuroscout
expose:
- "8000"
volumes:
Expand Down
10 changes: 6 additions & 4 deletions neuroscout/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7-buster
FROM python:3.8-bullseye
ARG DEBIAN_FRONTEND=noninteractive

RUN mkdir -p /usr/src/app
Expand All @@ -7,10 +7,12 @@ WORKDIR /usr/src/app
RUN apt-get -qq update
RUN apt-get install -yq ffmpeg tesseract-ocr apt-transport-https libnss3 xvfb
RUN pip install -e git+https://github.com/PsychoinformaticsLab/pliers.git#egg=pliers
RUN pip install clarifai duecredit google-api-python-client IndicoIo librosa>=0.6.3 pysrt pytesseract spacy rev_ai
RUN pip install clarifai duecredit google-api-python-client librosa>=0.6.3 pysrt pytesseract spacy rev_ai

RUN wget -O- http://neuro.debian.net/lists/buster.us-nh.libre | tee /etc/apt/sources.list.d/neurodebian.sources.list && apt-key adv --recv-keys --keyserver hkps://keyserver.ubuntu.com 0xA5D32F012649A5A9
RUN apt-get update && apt-get install -yq datalad && pip install datalad
RUN wget -O- http://neuro.debian.net/lists/bullseye.us-tn.libre | tee /etc/apt/sources.list.d/neurodebian.sources.list
RUN apt-key adv --recv-keys --keyserver hkps://keyserver.ubuntu.com 0xA5D32F012649A5A9
RUN apt-get update
RUN apt-get install -yq datalad-container

RUN curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
RUN echo "deb https://deb.nodesource.com/node_12.x buster main" | tee /etc/apt/sources.list.d/nodesource.list
Expand Down
2 changes: 1 addition & 1 deletion neuroscout/populate/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .utils import add_to_bibliography
from pathlib import Path
from datalad.api import install, get
from datalad.distribution.utils import _get_installationpath_from_url
from datalad.core.distributed.clone import _get_installationpath_from_url
from bids.layout import BIDSLayout
from ..models import Dataset

Expand Down
5 changes: 3 additions & 2 deletions neuroscout/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ blinker==1.4
celery
citeproc-py==0.4.0
citeproc-py-styles==0.1.1
datalad==0.10.2
datalad
dataclasses==0.6
decorator==4.0.11
docopt==0.6.2
duecredit==0.6.1
-e git+https://github.com/adelavega/pybids@0.13.1-patch#egg=pybids
pynv==0.2
Flask==1.1.1
Flask==1.1.4
flask-apispec==0.10.0
Flask-Caching==1.10.1
Flask-cors==3.0.9
Expand Down Expand Up @@ -66,6 +66,7 @@ scipy
sentry-sdk[flask]==0.13
soundfile
pytesseract
werkzeug<2.0
SQLAlchemy==1.3.0
shortuuid==1.0.1
webargs==6.1.1
Expand Down
2 changes: 1 addition & 1 deletion postgres/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM postgres:12
RUN apt-get update && apt-get install -y dos2unix
RUN apt-get install -yq python-pip python-dev build-essential
RUN apt-get install -yq python3-pip python-dev build-essential
RUN apt-get install -yq cron
RUN pip install awscli
COPY pg_dump-to-s3 /home
Expand Down