Skip to content

Commit

Permalink
Merge branch 'main' of github.com:l1ghthouse/lts_stats
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieVeitch committed Dec 18, 2022
2 parents 1980a30 + 4ea4240 commit 598fe0f
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 1 deletion.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
1 change: 1 addition & 0 deletions .env-sample
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
LIGHTHOUSE_MONGO_KEY=
40 changes: 40 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Create and publish a Docker image

on:
release:
types: [published]
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

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

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

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env
.idea
37 changes: 37 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM python:3.10.9-bullseye as base

# Setup env
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONFAULTHANDLER 1


FROM base AS python-deps

# Install pipenv and compilation dependencies
RUN pip install pipenv
RUN apt-get update && apt-get install -y --no-install-recommends gcc

# Install python dependencies in /.venv
COPY Pipfile .
COPY Pipfile.lock .
RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy


FROM base AS runtime

# Copy virtual env from python-deps stage
COPY --from=python-deps /.venv /.venv
ENV PATH="/.venv/bin:$PATH"

# Create and switch to a new user
RUN useradd --create-home appuser
WORKDIR /home/appuser
USER appuser

# Install application into container
COPY . .

# Run the application
CMD ["python", "-m", "streamlit", "run", "spreadsheet/webapp.py"]
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# lts_stats
1. Add connection string to environment variables - variable name should be LIGHTHOUSE_MONGO_KEY
2. Install relevant packages from Pipfile
3. run python -m streamlit run spreadsheet/webapp.py in the terminal (will use port 8501)
3. run python -m streamlit run spreadsheet/webapp.py in the terminal (will use port 8501)

# using docker for dev
1. create .env file in root directory, add LIGHTHOUSE_MONGO_KEY=<your connection string>
2. docker build -t lts_stats .
3. docker run -p 8501:8501 --env-file .env lts_stats

0 comments on commit 598fe0f

Please sign in to comment.