Skip to content

Instantly share code, notes, and snippets.

@bademux
Last active November 26, 2022 15:31
Show Gist options
  • Save bademux/76bfc0ef754468bb39946b6f95620c74 to your computer and use it in GitHub Desktop.
Save bademux/76bfc0ef754468bb39946b6f95620c74 to your computer and use it in GitHub Desktop.
Sensor Watch Builder Dockerfile
#use DOCKER_BUILDKIT=1 to cache downloaded layer and --output to export built Artefact
FROM scratch as caching-downloader
ADD https://github.com/bademux/Sensor-Watch/archive/refs/heads/feature/vendoring_ext_libs.tar.gz /sensor-watch.tar.gz
#DOCKER_BUILDKIT=1 docker build --file builder.Dockerfile -t sensor-watch-builder --target builder . && docker run -it -p 8000:8000 sensor-watch-builder and then open http://localhost:8000
FROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && apt install -y --no-install-recommends make libnewlib-arm-none-eabi gcc-arm-none-eabi emscripten &&\
rm -rf /var/lib/apt/lists/*
RUN adduser --disabled-password user
USER user
WORKDIR $HOME/sensor-watch
COPY --chown=user --from=caching-downloader / /tmp
RUN tar -zxvf /tmp/sensor-watch.tar.gz --strip-components=1
RUN mkdir out &&\
make -C movement/make &&\
cp movement/make/build/*.uf2 out &&\
emmake make -C movement/make 'BUILD=build-simulator' &&\
cp movement/make/build-simulator/*.html movement/make/build-simulator/*.js movement/make/build-simulator/*.wasm out &&\
rm -rf movement/make/build*
EXPOSE 8000
CMD ["python3", "-m", "http.server", "8000", "-d", "out"]
#DOCKER_BUILDKIT=1 docker build --file builder.Dockerfile --target exporter --output type=local,dest=./ .
FROM scratch AS exporter
COPY --from=builder /home/user/sensor-watch/out /
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment