-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:l1ghthouse/lts_stats
- Loading branch information
Showing
6 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
LIGHTHOUSE_MONGO_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.env | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |