Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a better Docker build script + update Dockerfile #4222

Merged
merged 22 commits into from
Dec 8, 2018
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
45a89f9
Add a Docker build script
Oct 23, 2018
aa01835
Add usage and error messages
Oct 23, 2018
8936d19
Add -r to reads
vomindoraan Oct 23, 2018
6d3a2ff
Add keyboard:keymap form, improve script
vomindoraan Oct 24, 2018
852129f
Add target argument, change usage forms in script
vomindoraan Oct 24, 2018
6dd7b8d
Add check for more than 3 args in keyboard:keymap:target form
vomindoraan Oct 24, 2018
2fce454
Change Docker base image to debian, use community repo
vomindoraan Oct 24, 2018
688c70b
Change build command format to keyboard:keymap
vomindoraan Oct 24, 2018
b67b170
Call make directly in container run command
vomindoraan Oct 25, 2018
247969c
Simplify script, remove 3-arg form
vomindoraan Oct 25, 2018
6b8c947
Add COPY to Dockerfile so images are usable in and of themselves
vomindoraan Oct 25, 2018
b23fd4f
Add USB pass-through for Linux and docker-machine hosts
vomindoraan Oct 25, 2018
ee6bfbc
Read directly into variables instead of array
vomindoraan Oct 25, 2018
882fe20
Alphabetically sort dependencies in Dockerfile
Oct 25, 2018
ecdf90e
Set executable bit on util/docker_build.sh
Nov 2, 2018
ca1b367
Update Docker docs
vomindoraan Nov 4, 2018
04f92da
Add warning about Docker on Windows
vomindoraan Nov 4, 2018
7417d5d
Expand comment in docs
vomindoraan Nov 5, 2018
2da3e73
Check docker-machine exit code instead of string
vomindoraan Nov 9, 2018
bb3c51e
Only match --help with whole arguments
vomindoraan Nov 9, 2018
f4e7233
Make script POSIX-compliant
vomindoraan Nov 9, 2018
e115747
Convert script indentation to tabs
vomindoraan Nov 9, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
FROM debian:jessie
MAINTAINER Erik Dasque <[email protected]>
FROM debian

RUN apt-get update && apt-get install --no-install-recommends -y build-essential \
gcc \
unzip \
wget \
zip \
gcc-avr \
binutils-avr \
RUN apt-get update && apt-get install --no-install-recommends -y \
avr-libc \
avrdude \
binutils-arm-none-eabi \
binutils-avr \
build-essential \
dfu-programmer \
dfu-util \
gcc \
gcc-arm-none-eabi \
binutils-arm-none-eabi \
libnewlib-arm-none-eabi \
gcc-avr \
git \
libnewlib-arm-none-eabi \
software-properties-common \
avrdude \
unzip \
wget \
zip \
&& rm -rf /var/lib/apt/lists/*

ENV keyboard=ergodox
ENV subproject=ez
ENV keymap=default
ENV KEYBOARD=ergodox_ez
ENV KEYMAP=default

VOLUME /qmk_firmware
WORKDIR /qmk_firmware
COPY . .

VOLUME /qmk
WORKDIR /qmk
CMD make clean ; make keyboard=${keyboard} subproject=${subproject} keymap=${keymap}
CMD make $KEYBOARD:$KEYMAP
7 changes: 3 additions & 4 deletions docs/getting_started_build_tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,15 @@ If this is a bit complex for you, Docker might be the turn-key solution you need
```bash
# You'll run this every time you want to build a keymap
# modify the keymap and keyboard assignment to compile what you want
# defaults are ergodox/default
# defaults are ergodox_ez:default

docker run -e keymap=gwen -e keyboard=ergodox_ez --rm -v $('pwd'):/qmk:rw edasque/qmk_firmware
docker run --rm -e KEYBOARD=planck/rev6 -e KEYMAP=default -v $('pwd'):/qmk:rw qmkfm/qmk_firmware
```

On Windows Docker seems to have issues with the VOLUME tag in Dockerfile, and `$('pwd')` won't print a Windows compliant path; use full path instead, like this:

```bash
docker run -e keymap=default -e keyboard=ergodox_ez --rm -v D:/Users/Sacapuces/Documents/Repositories/qmk:/qmk:rw edasque/qmk_firmware

docker run --rm -e KEYBOARD=planck/rev6 -e KEYMAP=default -v C:/Users/QMK/Projects/qmk:/qmk:rw qmkfm/qmk_firmware
```

This will compile the targeted keyboard/keymap and leave it in your QMK directory for you to flash.
Expand Down
43 changes: 43 additions & 0 deletions util/docker_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

USAGE="Usage: $0 [keyboard[:keymap[:target]]]"

# Check preconditions
if [[ $* =~ "--help" ]]; then
echo "$USAGE"
exit 0
elif [[ $# -gt 1 ]]; then
echo "$USAGE" >&2
exit 1
elif [[ ! $(command -v docker) ]]; then
echo "Error: docker not found" >&2
echo "See https://docs.docker.com/install/#supported-platforms for installation instructions" >&2
exit 2
fi

# Determine arguments
if [[ $# -eq 0 ]]; then
read -rp "keyboard=" keyboard
[[ -n $keyboard ]] && read -rp "keymap=" keymap
[[ -n $keymap ]] && read -rp "target=" target
else
IFS=':' read -r keyboard keymap target x <<< "$1"
if [[ -n $x ]]; then
echo "$USAGE" >&2
exit 1
fi
fi
if [[ -n $target ]]; then
if [[ $(uname) == "Linux" || $(docker-machine active 2>/dev/null) ]]; then
usb_args="--privileged -v /dev/bus/usb:/dev/bus/usb"
else
echo "target requires docker-machine to run on your platform" >&2
echo "See http://gw.tnode.com/docker/docker-machine-with-usb-support-on-windows-macos" >&2
exit 3
fi
fi
dir=$(pwd -W 2>/dev/null) || dir=$PWD # Use Windows path if on Windows

# Run container and build firmware
docker run --rm $usb_args -v "$dir":/qmk_firmware qmkfm/qmk_firmware \
make "$keyboard${keymap:+:$keymap}${target:+:$target}"