diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml index 982a55c7..48bc08dc 100644 --- a/.github/workflows/backend.yml +++ b/.github/workflows/backend.yml @@ -9,11 +9,46 @@ on: - master jobs: + build: + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + + runs-on: ${{ matrix.os }} + + defaults: + run: + working-directory: backend + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: 3.8 + - run: python -m pip install -r requirements.txt -r requirements-dev.txt + - run: python -m PyInstaller --onefile app.py + - uses: actions/upload-artifact@v2 + with: + name: "server_${{ matrix.os }}" + path: backend/dist + release: - runs-on: ubuntu-latest if: github.ref == 'refs/heads/master' + + strategy: + matrix: + os: [ubuntu-latest] + + runs-on: ${{ matrix.os }} + + needs: build + steps: - uses: actions/checkout@v2 + - uses: actions/download-artifact@v2 + with: + name: "server_${{ matrix.os }}" + path: backend/dist - uses: docker/build-push-action@v1 with: dockerfile: backend/Dockerfile diff --git a/README.md b/README.md index 6f5211fb..548cac03 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,10 @@ This projects aims to offer a comprehensive guide to **record polysomnographic E - Fetch Flutter dependencies through the `Flutter` extension - Start dev server by running `python backend/app.py` +## Building the server as a single executable + +Run `python -m PyInstaller --onefile app.py` + ## Running the server locally - [Login](https://docs.github.com/en/free-pro-team@latest/packages/using-github-packages-with-your-projects-ecosystem/configuring-docker-for-use-with-github-packages#authenticating-with-a-personal-access-token) to Github Docker registry diff --git a/backend/Dockerfile b/backend/Dockerfile index a7e7c2b6..521dbf8a 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,5 +1,4 @@ -FROM python -COPY backend /backend -WORKDIR /backend -RUN pip3 install -r requirements.txt --no-cache-dir -CMD ["python", "app.py"] +FROM ubuntu +COPY backend/dist/ / +RUN chmod +x /app +CMD /app diff --git a/backend/requirements-dev.txt b/backend/requirements-dev.txt new file mode 100644 index 00000000..f34f4e4e --- /dev/null +++ b/backend/requirements-dev.txt @@ -0,0 +1 @@ +pyinstaller==4.0