Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.

Commit

Permalink
Cleanup workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
zewelor committed Dec 27, 2021
1 parent f84cbb0 commit 9e6eb27
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 51 deletions.
34 changes: 0 additions & 34 deletions .github/workflows/docker.yml

This file was deleted.

52 changes: 52 additions & 0 deletions .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build and push

on:
pull_request:
branches: [ master ]
push:
branches: [ master ]

jobs:
test_build:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build
id: docker_build
uses: docker/build-push-action@v2
with:
platforms: linux/amd64,linux/arm64, linux/arm/v7

build_and_push:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
needs: test_build
steps:
- name: checkout code
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
platforms: linux/amd64,linux/arm64, linux/arm/v7
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
tags: |
${{ secrets.DOCKER_USERNAME }}/bt-mqtt-gateway:${{ github.sha }}
${{ secrets.DOCKER_USERNAME }}/bt-mqtt-gateway:latest
22 changes: 10 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
FROM python:3.8-alpine3.12
FROM python:3.8-alpine

ENV DEBUG false

RUN mkdir application
WORKDIR /application

COPY requirements.txt /application

RUN apk add --no-cache tzdata bluez bluez-libs sudo bluez-deprecated && \
ln -s /config.yaml ./config.yaml && \
pip install -r requirements.txt

RUN mkdir /application
COPY . /application

RUN apk add --no-cache --virtual build-dependencies git bluez-dev musl-dev make gcc glib-dev musl-dev && \
pip install `./gateway.py -r all` && \
WORKDIR /application

RUN apk add --no-cache tzdata bluez bluez-libs sudo bluez-deprecated && \
apk add --no-cache --virtual build-dependencies git bluez-dev musl-dev make gcc glib-dev musl-dev && \
pip install --no-cache-dir -r requirements.txt && \
pip install --no-cache-dir `./gateway.py -r all` && \
apk del build-dependencies

COPY ./start.sh /start.sh
RUN chmod +x /start.sh

VOLUME /application/config.yaml

ENTRYPOINT ["/bin/sh", "-c", "/start.sh"]
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
#environment:
# - DEBUG=true
volumes:
- ./config.yaml:/config.yaml
- ./config.yaml:/application/config.yaml
cap_add:
- NET_ADMIN
- NET_RAW
Expand Down
6 changes: 2 additions & 4 deletions start.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#!/bin/sh

if ! [ -f '/config.yaml' ]; then
echo "There is no config.yaml! An example is created."
cp /application/config.yaml.example /config.yaml.example
if ! [ -f '/application/config.yaml' ]; then
echo "There is no config.yaml! Check example config: https://github.com/zewelor/bt-mqtt-gateway/blob/master/config.yaml.example"
exit 1
fi

cd /application
if [ "$DEBUG" = 'true' ]; then
echo "Start in debug mode"
python3 ./gateway.py -d
Expand Down

0 comments on commit 9e6eb27

Please sign in to comment.