---
# System prepended metadata

title: Untitled

---

```
FROM python:3.8.16 AS build-stage

# Copy device manager src code
WORKDIR /app
ADD . .

# Install requirement and flake8
RUN pip install -r requirements.txt
RUN flake8 --max-line-length=160 $(find . -not \( -path ./.env -prune \) -not \( -path ./app/tests -prune \) -not \( -path ./app/core -prune \) -not \( -path ./build -prune \) -type f -name \*.py)
RUN cd app && ENV_FOR_DYNACONF=testing ../test.sh

# Build device manager with pyinstaller
RUN pyinstaller -F \
                --onefile --additional-hooks-dir hooks/ \
                --hidden-import uvicorn \
                --hidden-import uvicorn.logging \
                --hidden-import uvicorn.loops.auto \
                --hidden-import uvicorn.loops.asyncio \
                --hidden-import uvicorn.loops.uvloop \
                --hidden-import uvicorn.loops \
                --hidden-import uvicorn.protocols \
                --hidden-import uvicorn.protocols.http \
                --hidden-import uvicorn.protocols.http.auto \
                --hidden-import uvicorn.protocols.http.h11_impl \
                --hidden-import uvicorn.protocols.http.httptools_impl \
                --hidden-import uvicorn.protocols.websockets \
                --hidden-import uvicorn.protocols.websockets.auto \
                --hidden-import uvicorn.protocols.websockets.wsproto_impl \
                --hidden-import uvicorn.protocols.websockets_impl \
                --hidden-import uvicorn.lifespan \
                --hidden-import uvicorn.lifespan.on \
                --hidden-import uvicorn.lifespan.off \
                -n devicemgr --distpath . app/devicemgr_main.py

FROM python:3.8-slim AS production-stage

# Create app directory
WORKDIR /app
ADD run.sh .
RUN ["chmod", "+x", "run.sh"]
RUN ["mkdir", "images"]

# Copy device manager binary code
COPY --from=build-stage /app/devicemgr /app
ADD app/config/static_config.json config/static_config.json

# Copy coverage report
COPY --from=build-stage /app/app/htmlcov /app/htmlcov

EXPOSE 3000
CMD ["./run.sh"]

```

```
from PyInstaller.utils.hooks import collect_data_files
datas = collect_data_files('grpc')
```


```
#!/bin/sh -e

trap "trap - TERM && kill -- -$$" TERM

service_run() {
  /app/monitoringmgr &
  wait
}

service_run

```

```
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

.env

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
```

```
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIN0uOmBeHTxWZdNeObQ684W8SaDYpvyPs1TgyHS0pYMD user@linux-server

```

```
#!/bin/sh -e

[ -d .env ] || virtualenv -p python3.8 .env
. .env/bin/activate
cp ../hermesbackendlibrary/hermes_backend_lib-1.0.0-py3-none-any.whl .
pip install --force-reinstall --no-cache-dir hermes_backend_lib-1.0.0-py3-none-any.whl
pip install -r requirements.txt
```