Skip to content

Commit

Permalink
Update py version
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Solymos <psolymos@gmail.com>
  • Loading branch information
psolymos committed Jul 1, 2024
1 parent 75d695c commit 7ba2d2c
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 8 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/py-shiny.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build and Push Docker Image for faithful/py-shiny

on:
push:
branches: [ "main" ]
paths: [ "py-shiny/**"]
pull_request:
branches: [ "main" ]
paths: [ "py-shiny/**"]

env:
SHINY_SETUP: py-shiny
TAG: latest

permissions:
packages: write

jobs:
build-and-push-image:
runs-on: ubuntu-latest
steps:

- name: 'Checkout GitHub Action'
uses: actions/checkout@v4

- name: 'Docker metadata'
id: meta
uses: docker/metadata-action@v5
with:
labels: |
maintainer=Peter Solymos
org.opencontainers.image.title=Faithful
org.opencontainers.image.description=Old Faithful Shiny app
org.opencontainers.image.vendor=Hosting Shiny Book Project
- name: 'Login to GitHub Container Registry'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}

- name: 'Build and push'
uses: docker/build-push-action@v6
with:
context: ./${{ env.SHINY_SETUP }}
file: ./${{ env.SHINY_SETUP }}/Dockerfile
push: true
tags: ghcr.io/${{ github.repository }}/${{ env.SHINY_SETUP }}:${{ env.TAG }}
labels: ${{ steps.meta.outputs.labels }}
12 changes: 4 additions & 8 deletions py-shiny/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
FROM python:3.9

# Add user an change working directory and user
RUN addgroup --system app && adduser --system --ingroup app app
WORKDIR /home/app

# Install requirements
COPY app/requirements.txt .
RUN pip install --no-cache-dir --upgrade -r requirements.txt

# Copy the app
COPY app .

# Run app on port 8080
# RUN mkdir .config
# ENV MPLCONFIGDIR=/home/app/.config
RUN chown app:app -R /home/app
USER app

## Issue: if I set user to 'user' I get various errors...
# USER app
RUN mkdir .config
ENV MPLCONFIGDIR=/home/app/.config
ENV HOME=/home/app

EXPOSE 3838
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "3838"]
1 change: 1 addition & 0 deletions py-shiny/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__

0 comments on commit 7ba2d2c

Please sign in to comment.