Skip to content

Commit

Permalink
Amazing new cards (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
KenwoodFox authored Jan 5, 2025
1 parent e14b2d3 commit 4341546
Show file tree
Hide file tree
Showing 27 changed files with 1,148 additions and 979 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/build_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: ProjectHUD CI

on:
push:
branches:
- "*"
tags:
- "*"

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

jobs:
formatblack:
name: Black Formatter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Check files using the black formatter
uses: rickstaa/action-black@v1
id: action_black
with:
black_args: "."

- name: Annotate diff changes using reviewdog
if: steps.action_black.outputs.is_formatted == 'true'
uses: reviewdog/action-suggester@v1
with:
tool_name: blackfmt

build-and-publish-image:
name: Build and Publish Registry Image
runs-on: ubuntu-latest
needs: [formatblack] # Keeps the bot from updating the image if its not tested/formatted

permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true

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

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

- name: Extract Version information for project hud
id: extract_hash
run: |
echo BUILD_HASH=$(git describe --abbrev=8 --always --tags --dirty) >> $GITHUB_ENV
- name: Get branch name
id: branch-name
uses: tj-actions/[email protected]

- name: Get a docker ready tag
run: |
echo "${{ steps.branch-name.outputs.current_branch }}"
echo "${{ steps.meta.outputs.tags }}"
echo "CUSTOM_TAG=ghcr.io/frc-1721/project_hud-bot:$(echo "${{ steps.branch-name.outputs.current_branch }}" | sed 's/[^a-zA-Z0-9]/-/g; s/[A-Z]/\L&/g')" >> $GITHUB_ENV
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
build-args: |
GIT_COMMIT=${{ env.BUILD_HASH }}
DEBUG=False
tags: ${{ env.CUSTOM_TAG }}
labels: ${{ steps.meta.outputs.labels }}
60 changes: 19 additions & 41 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,48 +1,26 @@
FROM python:3.12-slim
# Use the official Python slim image as the base image
FROM python:3.10-slim

# Authors
LABEL authors="[email protected]"
# Set the working directory inside the container
WORKDIR /app

# Set the name of our app
ARG APP_NAME=project-hud
ENV APP_NAME=${APP_NAME}
# Copy requirements.txt and install dependencies globally
COPY requirements.txt .
RUN pip install --upgrade pip && pip install -r requirements.txt

# Get the current git version
ARG GIT_COMMIT
ENV GIT_COMMIT=$GIT_COMMIT

# App home
ARG HOME="/app"
ENV HOME=${HOME}

# Upgrade pip
RUN pip install --upgrade pip --no-cache-dir

# Set workdir
WORKDIR ${HOME}
# Copy the app code to the container
COPY . .

# Add any packages we need
RUN apt update && apt install python-dev-is-python3 -y
# Expose port 5000 for the Flask app
EXPOSE 5000

# Copy in all requirements
ADD requirements requirements/

# Install normal reqs
RUN pip install -r requirements/requirements.txt --no-cache-dir
# Install testing reqs
RUN pip install -r requirements/test_requirements.txt --no-cache-dir

# Copy in everything else
ADD . ${HOME}
# Add /bin to path
ENV PATH $PATH:${HOME}/bin

# Install our app in edit mode using pip
RUN pip install -e ${HOME} --no-cache-dir
# Bake the git commit into the env
ARG GIT_COMMIT
ENV GIT_COMMIT=$GIT_COMMIT

# Drop root and change ownership of /app to app:app
RUN chown -R ${USER_ID}:${GROUP_ID} ${HOME}
USER ${USER_ID}
# Healthcheck to ensure the service is up
# HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
# CMD curl --fail http://localhost:5000/ || exit 1

# Run the entrypoint bin
ENTRYPOINT ["entrypoint"]
# Run Gunicorn without virtual environment
ENTRYPOINT ["gunicorn", "-b", "0.0.0.0:5000", "-w", "2", "-t", "120", "wsgi:app"]
43 changes: 0 additions & 43 deletions Makefile

This file was deleted.

5 changes: 4 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ verify_ssl = true
name = "pypi"

[packages]
flask = "*"
flask-sqlalchemy = "*"
flask-migrate = "*"
psycopg2-binary = "*"
flask-socketio = "*"
flask = "*"
requests = "*"
pygithub = "*"
python-dotenv = "*"

[dev-packages]

Expand Down
Loading

0 comments on commit 4341546

Please sign in to comment.