Skip to content

Commit

Permalink
Merge pull request #3 from JacekZubielik/dev
Browse files Browse the repository at this point in the history
Changes to release action settings and lint.
  • Loading branch information
JacekZubielik authored May 7, 2024
2 parents 44fe52f + 286b532 commit a17d51c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 31 deletions.
1 change: 0 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ jobs:
uses: github/super-linter@v6
env:
VALIDATE_PYTHON: true
VALIDATE_DOCKERFILE_HADOLINT: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20 changes: 11 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ jobs:
run: cat Release.txt

- name: Generate Changelog
run: echo "# What's Changed" > ${{ github.workspace }}-CHANGELOG.txt
run: echo "# Changelog" > ${{ github.workspace }}-CHANGELOG.txt

- name: Generate release notes
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/v')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: jacekzubielik/docker-oled-evo-sabre
Expand All @@ -105,8 +105,8 @@ jobs:
files: |
release_${{ matrix.release_suffix }}
LICENCE
draft: true
prerelease: true
draft: false
prerelease: false
generate_release_notes: true
body_path: ${{ github.workspace }}-CHANGELOG.txt

Expand All @@ -123,19 +123,19 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
gorabbit/docker-oled-evo-sabre
ghcr.io/jacekzubielik/docker-oled-evo-sabre
ghcr.io/docker-oled-evo-sabre
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
# type=sha
# type=match,pattern=\d.\d.\d
# type=ref,event=tag

- name: Login to DockerHub
# if: github.event_name != 'pull_request'
Expand All @@ -158,7 +158,9 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
platforms: linux/amd64 #,linux/arm64
# cache-from: type=local,src=/tmp/.buildx-cache
# cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

# - name: Move cache
# run: |
Expand Down
19 changes: 8 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ LABEL org.opencontainers.image.source="https://github.com/jacekzubielik/docker-o

# Prepare environment
RUN mkdir /app \
&& apt get update \
&& apt get -y install curl telnet \
&& apt get clean \
&& apt-get update \
&& apt-get -y install curl telnet \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& useradd -u 1000 -G sudo -U -m -s /bin/bash oleduser \
&& chown oleduser:oleduser /app \
Expand All @@ -23,21 +23,18 @@ WORKDIR /app

# Install dependencies
FROM base as python-deps
RUN apt get update \
&& apt get -y install build-essential \
&& apt get clean \
RUN apt-get update \
&& apt-get -y install build-essential \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& pip install --upgrade pip wheel

# Install dependencies
COPY --chown=oleduser:oleduser requirements.txt /app/
COPY --chown=oleduser:oleduser ./app/requirements.txt /app/
USER oleduser
RUN pip install --user --no-cache-dir numpy \
&& pip install --user --no-cache-dir -r requirements.txt
RUN pip install --user --no-cache-dir -r requirements.txt

COPY ./app /app

# RUN pip install -r requirements.txt --no-cache-dir
CMD ["sh", "-c", "python3 -u oled4docker.py MAC=$MAC OLED=$OLED LOGFILE=$LOGFILE LOCATION=$LOCATION LMSIP=$LMSIP"]

HEALTHCHECK CMD curl --fail http://localhost:3000 || exit 1
20 changes: 10 additions & 10 deletions app/oled4docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@
from dotenv import load_dotenv
load_dotenv()

print('TZ: {}'.format(environ['TZ']))
print('PUID: {}'.format(environ['PUID']))
print('PGID: {}'.format(environ['PGID']))
print('OLED: {}'.format(environ['OLED']))
print('LMSIP: {}'.format(environ['LMSIP']))
print('MAC: {}'.format(environ['MAC']))
print('LOGFILE: {}'.format(environ['LOGFILE']))
print('LOCATION: {}'.format(environ['LOCATION']))
print('TZ: {}'.format(environ["TZ"]))
print('PUID: {}'.format(environ["PUID"]))
print('PGID: {}'.format(environ["PGID"]))
print('OLED: {}'.format(environ["OLED"]))
print('LMSIP: {}'.format(environ["LMSIP"]))
print('MAC: {}'.format(environ["MAC"]))
print('LOGFILE: {}'.format(environ["LOGFILE"]))
print('LOCATION: {}'.format(environ["LOCATION"]))

#====================
# Ensure all required environment variables are set
try:
os.environ['LOGFILE']
os.environ["LOGFILE"]
except KeyError:
print('[error]: `$LOGFILE` environment variable required')
print('[error]: "$LOGFILE" environment variable required')
sys.exit(1)

File_Log_Format = "%(levelname)s %(asctime)s - %(message)s"
Expand Down

0 comments on commit a17d51c

Please sign in to comment.