Skip to content

Commit

Permalink
Merge pull request #59 from mlexchange/actions-for-spin-deployment
Browse files Browse the repository at this point in the history
Actions for spin deployment
  • Loading branch information
hannahker authored Jul 26, 2023
2 parents 4db3000 + ff26237 commit 790b44c
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 2 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/publish-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Create and publish image

on:
push:
branches: ['main']
tags: ['v*']

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM python:3.9

# Create and set working directory
WORKDIR /app

# Install Python dependencies
RUN python -m pip install --upgrade pip
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

# Copy the remainder of the code into the image
COPY . ./

EXPOSE 8075
# Run Dash app with gunicorn
CMD ["gunicorn", "-b", "0.0.0.0:8075", "--reload", "app:server"]
# Better than the alternative running of app.py directly with
#CMD ["python", "app.py"]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ pip install -r requirements.txt
2. Configure a connection to the Tiled server via a `.env` file with the following environment variables:

```
TILED_URI='https://mlex-segmentation.als.lbl.gov'
API_KEY='<key-provided-on-request>'
TILED_URI=https://mlex-segmentation.als.lbl.gov
API_KEY=<key-provided-on-request>
```

3. Start a local server:
Expand Down
24 changes: 24 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '3.7'

services:
app:
container_name: highres_seg_demo
build: .
command: 'gunicorn -b 0.0.0.0:8075 --reload app:server'
environment:
TILED_URI: '${TILED_URI}'
API_KEY: '${API_KEY}'
volumes:
- ./app.py:/app/app.py
- ./callbacks:/app/callbacks
- ./components:/app/components
- ./utils:/app/utils
ports:
- '8075:8075'

# networks:
# - computing_api_default

# networks:
# computing_api_default:
# external: true

0 comments on commit 790b44c

Please sign in to comment.