diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml deleted file mode 100644 index 3314705..0000000 --- a/.github/workflows/docker-publish.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Docker - -on: - push: - branches: - - master - - Dockerfile-use-installer - pull_request: - branches: - - master - - Dockerfile-use-installer - workflow_dispatch: - -env: - IMAGE_NAME: fomu-toolchain - -jobs: - push: - runs-on: ubuntu-latest - if: github.event_name == 'push' - - steps: - - uses: actions/checkout@v2 - - - name: Build image - run: docker build ./dockerfiles --file dockerfiles/Dockerfile.use-installer --tag $IMAGE_NAME - - - name: Log into registry - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin - - - name: Push image - run: | - IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME - - # Change all uppercase to lowercase - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - - # Strip git ref prefix from version - VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') - - # Strip "v" prefix from tag name - [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') - - # Use Docker `latest` tag convention - [ "$VERSION" == "master" ] && VERSION=latest - - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - - docker tag $IMAGE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION \ No newline at end of file diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 5461572..146a27d 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -9,6 +9,7 @@ on: jobs: + run: strategy: fail-fast: false @@ -121,3 +122,50 @@ jobs: token: ${{ github.token }} tag: nightly files: ./** + + + container: + if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/master' || contains(github.ref, 'refs/tags/')) + needs: [ test ] + runs-on: ubuntu-latest + env: + IMAGE_NAME: fomu-toolchain + + steps: + + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - uses: actions/download-artifact@v2 + with: + name: fomu-toolchain-Linux + + - name: Build image + run: docker build -t $IMAGE_NAME -f Dockerfile . + + - name: Login to docker.io + uses: docker/login-action@v1 + with: + registry: docker.pkg.github.com + username: "${{ github.actor }}" + password: "${{ github.token }}" + + - name: Push image + run: | + IMAGE_ID=$(echo "docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME" | tr '[A-Z]' '[a-z]') + + # Strip git ref prefix from version + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + + # Strip "v" prefix from tag name + [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') + + # Use Docker `latest` tag convention + [ "$VERSION" == "master" ] && VERSION=latest + + echo IMAGE_ID=$IMAGE_ID + echo VERSION=$VERSION + + docker tag $IMAGE_NAME $IMAGE_ID:$VERSION + docker push $IMAGE_ID:$VERSION diff --git a/dockerfiles/99-fomu.rules b/99-fomu.rules similarity index 100% rename from dockerfiles/99-fomu.rules rename to 99-fomu.rules diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e1db57a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM python:3-slim-buster + +RUN apt-get update -qq \ + && DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \ + ca-certificates \ + libusb-1.0-0 \ + make \ + && apt-get autoclean && apt-get clean && apt-get -y autoremove \ + && update-ca-certificates \ + && rm -rf /var/lib/apt/lists + +ADD fomu-toolchain-Linux.tar.gz /opt + +ENV PATH=/opt/fomu-toolchain-Linux/bin:$PATH + +ENV USER=fomu +RUN adduser --disabled-password ${USER} + +RUN usermod -a -G plugdev ${USER} + +COPY 99-fomu.rules /etc/udev/rules.d/ + +USER ${USER} +WORKDIR /home/${USER} diff --git a/dockerfiles/Dockerfile.use-installer b/dockerfiles/Dockerfile.use-installer deleted file mode 100644 index 0f47089..0000000 --- a/dockerfiles/Dockerfile.use-installer +++ /dev/null @@ -1,76 +0,0 @@ -ARG IMAGE="python:3-slim-buster" - -#--- -# Place anything that is common to both the build and execution environment in base -# -FROM $IMAGE AS base - -RUN apt-get update -qq \ - && DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \ - ca-certificates \ - git \ - libusb-1.0-0 \ - make \ - wget \ - && apt-get autoclean && apt-get clean && apt-get -y autoremove \ - && update-ca-certificates \ - && rm -rf /var/lib/apt/lists - -# FROM base as builder -# Install necessary tools and source code and build from source here for ci/cd -# If any build or test return a non-zero exit code, the docker build stops -# with an error, which is nice for ci/cd like github actions. - -# FROM builder as test-builder -# Run regression tests on binaries built from source here - -# FROM builder as installer -# use COPY --from=builder to get the binaries from builder stage and -# create an installer from those binaries built from source here - -FROM base as release-candidate -# use COPY --from=builder to copy binaries into the right place here if built from source, -# or copy the installer with COPY --from=installer -# or use the pre-built released installer as we do here: -RUN wget https://github.com/im-tomu/fomu-toolchain/releases/download/v1.5.6/fomu-toolchain-linux_x86_64-v1.5.6.tar.gz && \ - tar -xvf fomu-toolchain-linux_x86_64-v1.5.6.tar.gz && \ - rm fomu-toolchain-linux_x86_64-v1.5.6.tar.gz - -ENV PATH=/fomu-toolchain-linux_x86_64-v1.5.6/bin:$PATH - -ENV USER=fomu -RUN adduser --disabled-password ${USER} -# RUN groupadd plugdev # error - already exists -RUN usermod -a -G plugdev ${USER} -COPY 99-fomu.rules /etc/udev/rules.d/99-fomu.rules -# RUN udevadm control --reload-rules -# RUN udevadm trigger -USER ${USER} -WORKDIR /home/${USER} - -# FROM release-candidate as test-release-candidate -# Run any tests on final image here - - -FROM release-candidate as fomu-toolchain - -# Below are some sample commands to build and run a docker images. -# Execute the docker build commands from within the dockerfiles folder. -# -# docker build -f Dockerfile.use-installer . -t fomu-toolchain -# -# Execute the docker run commands from the fomu-workshop folder -# or from your own project's folder as appropriate. -# -# docker run -it -v $(pwd):/home/fomu fomu-toolchain bash -# -# The --privileged param may be used to allow access to usb devices -# but it allows access to much more, and may be a security risk. -# There may be a better way to allow dfu-util and wishbone-tool to run -# docker run -it -v $(pwd):/home/fomu --privileged fomu-toolchain bash -# -# On my old laptop running ubuntu 20.04, I need to re-run the docker -# container after using dfu-util in order to use it again or to use -# wishbone-tool. Perhaps I am missing a dependency here? I installed -# udev and dfu-util above just to see if that would pull in something -# I missed, but I don't think it helped. I removed them again.