Merge pull request #21 from Thirsty2/Dockerfile-use-installer

Dockerfile use installer
This commit is contained in:
Sean Cross 2020-10-16 10:18:25 +08:00 committed by GitHub
commit f4fa48ee15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 128 additions and 0 deletions

51
.github/workflows/docker-publish.yml vendored Normal file
View File

@ -0,0 +1,51 @@
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

View File

@ -0,0 +1 @@
SUBSYSTEM=="usb", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="5bf0", MODE="0664", GROUP="plugdev"

View File

@ -0,0 +1,76 @@
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.