Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
name: Deploy

permissions:
contents: read
issues: write
pull-requests: write

on:
push:
branches:
- main
workflow_dispatch:

concurrency:
group: production
cancel-in-progress: true

jobs:
deploy:

runs-on: ubuntu-latest
environment:
name: development
url: http://${{ vars.PROD_HOST }}:3001/

steps:
- name: Setup SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.PROD_SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H ${{ vars.PROD_HOST }} >> ~/.ssh/known_hosts

- name: Deploy via SSH
run: |
ssh ${{ secrets.PROD_USER }}@${{ vars.PROD_HOST }} << 'EOF'
set -e

export COMPOSE_PROGRESS=plain
export NO_COLOR=1

export AWS_ACCESS_KEY_ID="${{ secrets.AWS_ACCESS_KEY_ID }}"
export AWS_SECRET_ACCESS_KEY="${{ secrets.AWS_SECRET_ACCESS_KEY }}"
export AWS_DEFAULT_REGION=us-west-2

APP_DIR="NodeFlow"
REPO_URL="https://github.com/jlab-sensing/NodeFlow.git"
BRANCH="${{ github.ref_name }}"

echo "::group::Cloning repository"
sudo rm -rf $APP_DIR
git clone -b "$BRANCH" "$REPO_URL" "$APP_DIR"
cd "$APP_DIR"
git fetch origin
git reset --hard ${{ steps.pr.outputs.sha }}
echo "::endgroup::"

echo "::group::Setting up env file"
aws s3 cp s3://nodeflow-ucsc/secrets .env
sed -i "s/localhost/${{ vars.PROD_HOST }}/g" .env
echo "::endgroup::"

echo "::group::Remove previous deployment"
docker ps -aq | xargs -r docker stop
docker ps -aq | xargs -r docker rm
docker system prune -af --volumes
docker volume prune -a -f
echo "::endgroup::"

echo "::group::Starting services"
docker compose pull --ignore-buildable
docker compose up -d --build
sleep 5
echo "::endgroup::"

echo "::group::Waiting for startup"
sleep 15
echo "::endgroup::"

echo "::group::Startup logs"
docker compose logs --no-color
echo "::endgroup::"
EOF

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Low Cost, Real-Time Automated Irrigation
| Python |
| Docker |

test for lint

## Getting Started

Expand All @@ -21,3 +20,5 @@ For documentation on the backend, refer to [backend readme](backend/README.md)
## Builders

- David Glover [dvdthr5](https://github.com/dvdthr5)

- John Madden [jmadden173](https://github.com/jmadden173)
8 changes: 6 additions & 2 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ WORKDIR /app
# copy files from source tree
COPY . .

EXPOSE 8001
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8001"]

# CI image with test-only dependencies and coverage reporting.
FROM base AS test

RUN pip install --no-cache-dir -r requirements-dev.txt

CMD ["pytest", "--cov=app", "--cov-report=term-missing", "--cov-report=xml:/app/coverage.xml"]


FROM base AS webserver

EXPOSE 8001
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8001"]
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ services:
build:
context: ./backend
dockerfile: Dockerfile
target: webserver
image: nodeflow-backend
env_file:
- ${ENV_FILE:-.env}
Expand Down
36 changes: 36 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,39 @@
## Introduction

The NodeFlow client is being built with [React](https://react.dev/), a component based web library

## Testing

We use vitest to run frontend tests. You can automatically run the frontend tests by running

```
npm run test:ci
```

## Linting

We use eslint as the frontend linter. You can check the current status of your files by running

```
npm run lint
```

Supported lint issues can be automatically fixed by running

```
npx eslint --fix
```

## Formatting

We use Prettier as the frontend formatter. You can check the formatting of the frontend by running

```
npm run format:check
```

and can automatically format the frontend files by running

```
npm run format
```
4 changes: 4 additions & 0 deletions frontend/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import react from '@vitejs/plugin-react'

export default defineConfig({
plugins: [react()],
server: {
host: true,
allowedHosts: true,
},
test: {
environment: 'jsdom',
setupFiles: './tests/setup.js',
Expand Down