Skip to content

Commit

Permalink
Merge pull request lancaster-university#41 from lancaster-university/…
Browse files Browse the repository at this point in the history
…feature/docker-export
  • Loading branch information
JohnVidler committed Jan 14, 2022
2 parents 969b1b5 + 2b4ad5a commit 9dff845
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
13 changes: 10 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:18.04
FROM ubuntu:18.04 as builder

RUN apt-get update -qq && \
apt-get install -y --no-install-recommends \
Expand All @@ -13,6 +13,13 @@ RUN apt-get update -qq && \
rm -rf /var/lib/apt/lists/*

# Project sources volume should be mounted at /app
WORKDIR /app
COPY . /opt/microbit-samples
WORKDIR /opt/microbit-samples

ENTRYPOINT ["python3", "build.py"]
RUN python3 build.py

FROM scratch AS export-stage
COPY --from=builder /opt/microbit-samples/MICROBIT.bin .
COPY --from=builder /opt/microbit-samples/MICROBIT.hex .

ENTRYPOINT ["/bin/bash"]
21 changes: 7 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ For backwards compatibility with [microbit-samples](https://github.com/lancaster
## Docker
You can use the [Dockerfile](https://github.com/lancaster-university/microbit-v2-samples/blob/master/Dockerfile) provided to build the samples, or your own project sources, without installing additional dependencies.

Run the following command to build the image locally:
Run the following command to build the image locally; the .bin and .hex files from a successful compile will be placed in a new `out/` directory:

```
docker build -t microbit-tools --output out .
```

To omit the final output stage (for CI, for example) run without the `--output` arguments:

```
docker build -t microbit-tools .
Expand All @@ -41,19 +47,6 @@ Run the following command to build the image locally:
- In the root of this repository type `python build.py`
- The hex file will be built `MICROBIT.HEX` and placed in the root folder.

## Docker
You can use the image you built previously to build the project sources in the current working directory (equivalent to executing `build.py`).

```
docker run -v $(pwd):/app --rm microbit-tools
```

You can also provide additional arguments like `--clean`.

```
docker run -v $(pwd):/app --rm microbit-tools --clean
```

# Developing
You will find a simple main.cpp in the `source` folder which you can edit. CODAL will also compile any other C/C++ header files our source files with the extension `.h .c .cpp` it finds in the source folder.

Expand Down

0 comments on commit 9dff845

Please sign in to comment.