Skip to content

Commit e7f5f90

Browse files
committed
Update docker build for v0.5.1
- Docker image now only contain the build environment, not the code. This save development time by not rebuilding docker image everytime source code change. - Build by mounting repo's directory into container, build output and intermediate artifacts is available for inspecting if build fail midway.
1 parent b952a5e commit e7f5f90

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

Dockerfile

+13-7
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@ RUN add-apt-repository ppa:team-gcc-arm-embedded/ppa
77
RUN add-apt-repository ppa:jonathonf/tup
88
RUN apt-get update
99
RUN apt-get -y upgrade
10-
RUN apt-get -y install gcc-arm-embedded openocd tup python3.7 build-essential git
10+
RUN apt-get -y install gcc-arm-embedded openocd tup python3.7 python3-yaml python3-jinja2 python3-jsonschema build-essential git
1111

1212
# Build step below does not know about debian's python naming schemme
1313
RUN ln -s /usr/bin/python3.7 /usr/bin/python
1414

15-
# Copy the firmware tree into the container
16-
RUN mkdir ODrive
17-
COPY . ODrive
15+
RUN mkdir -p ODrive
1816
WORKDIR ODrive/Firmware
1917

20-
# Hack around Tup's dependency on FUSE
21-
RUN tup generate build.sh
22-
RUN ./build.sh
18+
# Must attach the firmware tree into the container
19+
CMD \
20+
# Regenerate python interface
21+
python interface_generator_stub.py \
22+
--definitions odrive-interface.yaml \
23+
--template ../tools/enums_template.j2 \
24+
--output ../tools/odrive/enums.py && \
25+
# Hack around Tup's dependency on FUSE
26+
tup init && \
27+
tup generate build.sh && \
28+
./build.sh

dockerbuild.sh

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function cleanup {
22
echo "Removing previous build artifacts"
3-
rm -rf build
3+
rm -rf build/ Firmware/autogen Firmware/build Firmware/.tup
44
docker rm odrive-build-cont
55
}
66

@@ -13,14 +13,11 @@ function gc {
1313
function build {
1414
cleanup
1515

16-
echo "Building the firmware"
16+
echo "Building the build-environment image"
1717
docker build -t odrive-build-img .
1818

19-
echo "Create container"
20-
docker create --name odrive-build-cont odrive-build-img:latest
21-
22-
echo "Extract build artifacts"
23-
docker cp odrive-build-cont:ODrive/Firmware/build .
19+
echo "Build in container"
20+
docker run -v $(pwd):/ODrive --name odrive-build-cont odrive-build-img:latest
2421
}
2522

2623
function usage {

0 commit comments

Comments
 (0)