Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile UI build stage #83

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
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
20 changes: 1 addition & 19 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,6 @@ jobs:
base: ${{ github.event.repository.default_branch }}
head: HEAD
extra_args: --debug --only-verified


# Use Caching for npm
- name: Cache node modules
uses: actions/cache@v2
with:
working-directory: ./ui
path: |
node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-

- name: Install npm dependencies and build UI
run: |
cd ui
npm install
npm run build

- name: Login to Docker Hub
uses: docker/login-action@v1
Expand All @@ -62,7 +44,7 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and push
- name: Build and Push
uses: docker/build-push-action@v4
env:
VERSION: ${{ env.VERSION }}
Expand Down
34 changes: 20 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
FROM python:3.9
# Build Stage 1
# Build the UI
FROM node:12 AS node-builder

ENV DOCKER_DEPLOYMENT=1
WORKDIR /app/ui

RUN pip install torch
COPY ./ui/package.json .
RUN npm install --silent --production

COPY ./app/requirements.txt /tmp/requirements.txt
COPY ./ui .
RUN npm run build

RUN pip install -r /tmp/requirements.txt

# Build Stage 2
# Builds the backend as well as gets the built UI from Stage 1
FROM python:3.9
ENV CAPTURE_TELEMETRY=1

COPY ./app/models.py /tmp/models.py
WORKDIR /app

# cache the models
RUN python3 /tmp/models.py
COPY ./app/requirements.txt .
RUN pip install -r /app/requirements.txt

COPY ./app /app

COPY ./ui/build /ui

COPY ./run.sh /app/run.sh
# Cache the models
COPY ./app/models.py /tmp/models.py
RUN python3 /tmp/models.py

WORKDIR /app
COPY --from=node-builder /app/ui/build /ui
COPY ./run.sh .

VOLUME [ "/opt/storage" ]
ENV DOCKER_DEPLOYMENT=1

EXPOSE 80

CMD ./run.sh
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ add `-d` if you want to detach the container.

## Run from source
See CONTRIBUTING.md


- **gerev is also popular with some big names. 😉**

---
Expand Down
1 change: 1 addition & 0 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 1 addition & 1 deletion app/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
if os.name == 'nt':
STORAGE_PATH = Path(".gerev\\storage")
else:
STORAGE_PATH = Path('/opt/storage/') if IS_IN_DOCKER else Path(f'/home/{os.getlogin()}/.gerev/storage/')
STORAGE_PATH = Path('/tmp/storage/') if IS_IN_DOCKER else Path(f'/home/{os.getlogin()}/.gerev/storage/')

if not STORAGE_PATH.exists():
STORAGE_PATH.mkdir(parents=True)
Expand Down