From f4aa60887aa3ab3c8e6a469f451d4096b0e7e579 Mon Sep 17 00:00:00 2001 From: Anes Belfodil Date: Tue, 20 Oct 2020 21:46:03 -0400 Subject: [PATCH 1/3] Build and upload server as a single executable --- .github/workflows/backend.yml | 23 +++++++++++++++++++++++ backend/requirements-dev.txt | 1 + 2 files changed, 24 insertions(+) create mode 100644 backend/requirements-dev.txt diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml index 982a55c7..c58e94ee 100644 --- a/.github/workflows/backend.yml +++ b/.github/workflows/backend.yml @@ -9,6 +9,29 @@ 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' 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 From 91195b17dcd78f8fe60c05e7f07558a3ba71536d Mon Sep 17 00:00:00 2001 From: Anes Belfodil Date: Tue, 20 Oct 2020 21:55:43 -0400 Subject: [PATCH 2/3] Reduce image size --- .github/workflows/backend.yml | 14 +++++++++++++- backend/Dockerfile | 9 ++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml index c58e94ee..48bc08dc 100644 --- a/.github/workflows/backend.yml +++ b/.github/workflows/backend.yml @@ -33,10 +33,22 @@ jobs: 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/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 From 689179db970f346e0483e6b47fb8e8b5e0369674 Mon Sep 17 00:00:00 2001 From: Anes Belfodil Date: Wed, 21 Oct 2020 08:48:47 -0400 Subject: [PATCH 3/3] Add pyinstaller command to readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) 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