mirror of
https://github.com/im-tomu/fomu-toolchain.git
synced 2024-09-20 02:40:08 +00:00
Merge pull request #26 from umarcor/ci/docker-cleanup
ci: cleanup container sources
This commit is contained in:
commit
0beffe7124
51
.github/workflows/docker-publish.yml
vendored
51
.github/workflows/docker-publish.yml
vendored
@ -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
|
|
48
.github/workflows/update.yml
vendored
48
.github/workflows/update.yml
vendored
@ -9,6 +9,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
|
|
||||||
run:
|
run:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
@ -121,3 +122,50 @@ jobs:
|
|||||||
token: ${{ github.token }}
|
token: ${{ github.token }}
|
||||||
tag: nightly
|
tag: nightly
|
||||||
files: ./**
|
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
|
||||||
|
24
Dockerfile
Normal file
24
Dockerfile
Normal file
@ -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}
|
@ -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.
|
|
Loading…
Reference in New Issue
Block a user