Skip to content

Commit

Permalink
fleshed out code deploy, Dockerfile test
Browse files Browse the repository at this point in the history
  • Loading branch information
Michele Fabbri committed Apr 12, 2022
1 parent d69869e commit dce1c5f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 16 deletions.
51 changes: 38 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ on:
- dev

jobs:
run_tests:
run_jobs:
runs-on: ubuntu-latest
services:
postgres:
image: postgres
image: postgres:13
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
Expand All @@ -36,7 +36,7 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install dependecies
- name: Install python dependecies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
Expand All @@ -45,8 +45,8 @@ jobs:
PIP_USE_MIRRORS: true
- name: Run tests
run: |
sudo touch /var/log/alyx.log; sudo chmod 776 /var/log/alyx.log
sudo touch /var/log/alyx_json.log; sudo chmod 776 /var/log/alyx_json.log
sudo touch /var/log/alyx.log; sudo chmod 666 /var/log/alyx.log
sudo touch /var/log/alyx_json.log; sudo chmod 666 /var/log/alyx_json.log
cd alyx
mv alyx/settings_ci.py alyx/settings.py
coverage run manage.py test -n
Expand All @@ -59,20 +59,45 @@ jobs:
run: |
cd alyx
flake8 .
build:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Login to Docker Hub
- name: Generate pip freeze requirements.txt
run: |
pip freeze > requirements_frozen.txt
echo ">>> Contents of requirements_frozen.txt <<<"
cat requirements_frozen.txt
- name: Copy files to S3
shell: bash
env:
aws_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_KEY_ID }}
aws_s3_bucket: ${{ secrets.AWS_S3BUCKET_NAME }}
aws_region: ${{ secrets.AWS_REGION }}
run: |
sudo apt-get update && sudo apt-get -y install awscli
aws configure set aws_access_key_id $aws_key_id
aws configure set aws_secret_access_key $aws_secret_access_key
aws configure set default.region $aws_region
aws s3 cp requirements_frozen.txt s3://$aws_s3_bucket/github_actions/
echo "The current directory: "
pwd
echo "Files in scripts dir: "
ls scripts
echo "Files in scrips/deployment_examples dir: "
ls scripts/deployment_examples
aws s3 cp scripts/deployment_examples/alyx-docker/000-default-conf-alyx-dev s3://$aws_s3_bucket/github_actions/
# aws s3 cp scripts/deployment_examples/alyx-docker/apache-conf* s3://$aws_s3_bucket/github_actions/
# aws s3 cp scripts/deployment_examples/alyx-docker/cloudwatch_config.json* s3://$aws_s3_bucket/github_actions/
# aws s3 cp scripts/deployment_examples/alyx-docker/Dockerfile.ibl s3://$aws_s3_bucket/github_actions/
- name: Configure Docker login
if: ${{ github.ref == 'refs/heads/master' }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up Docker Buildx
if: ${{ github.ref == 'refs/heads/master' }}
uses: docker/setup-buildx-action@v1
- name: Build and push
- name: Build and push Docker base image
if: ${{ github.ref == 'refs/heads/master' }}
uses: docker/build-push-action@v2
with:
context: .
Expand Down
6 changes: 3 additions & 3 deletions scripts/deployment_examples/alyx-docker/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ RUN apt-get update && apt-get install -y \
&& apt-get autoremove \
&& rm -rf /var/lib/apt/lists/*

# Clone repo and configure virtual environment
RUN git clone --branch master https://github.com/cortex-lab/alyx.git /var/www/alyx
# Clone repo and configure virtual environment (not required when building with github actions?)
# RUN git clone --branch master https://github.com/cortex-lab/alyx.git /var/www/alyx
# Best practice for configuring python venv
ENV VIRTUAL_ENV=/var/www/alyx/venv
RUN virtualenv ${VIRTUAL_ENV} --python=python3
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
WORKDIR /var/www/alyx
RUN pip install -r requirements.txt
RUN pip install -r requirements_frozen.txt
WORKDIR /var/www/alyx/alyx
RUN pip install ONE-api

0 comments on commit dce1c5f

Please sign in to comment.