From 97caabb8c277f8bdddadc594b3a8f284405b925a Mon Sep 17 00:00:00 2001 From: Johan Brandhorst Date: Sat, 20 Oct 2018 23:56:37 +0100 Subject: [PATCH] Add Dockerfile --- Dockerfile | 23 +++++++++++++++++++++++ README.markdown | 19 +++++++++++++++---- docs/docker.rst | 14 ++++++++++++++ docs/index.rst | 1 + 4 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 Dockerfile create mode 100644 docs/docker.rst diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..6753fd91 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM golang:latest + +RUN wget -O- https://apt.llvm.org/llvm-snapshot.gpg.key| apt-key add - && \ + echo "deb http://apt.llvm.org/stretch/ llvm-toolchain-stretch-7 main" >> /etc/apt/sources.list && \ + apt-get update && \ + apt-get install -y llvm-7-dev + +RUN wget -O- https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + +COPY . /go/src/github.com/aykevl/tinygo + +RUN go install /go/src/github.com/aykevl/tinygo/ + +FROM golang:latest + +COPY --from=0 /go/bin/tinygo /go/bin/tinygo + +RUN wget -O- https://apt.llvm.org/llvm-snapshot.gpg.key| apt-key add - && \ + echo "deb http://apt.llvm.org/stretch/ llvm-toolchain-stretch-7 main" >> /etc/apt/sources.list && \ + apt-get update && \ + apt-get install -y llvm-7 + +ENTRYPOINT ["/go/bin/tinygo"] diff --git a/README.markdown b/README.markdown index 0d4d23bb..f652af18 100644 --- a/README.markdown +++ b/README.markdown @@ -66,6 +66,21 @@ Not yet supported: * introspection (if it ever gets implemented) * ... +## Installation + +See the [installation instructions](https://tinygo.readthedocs.io/en/latest/installation.html). + +### Running with Docker + +A docker container exists for easy access to the `tinygo` CLI: + +```sh +$ docker run --rm -v $(pwd):/src tinygo/tinygo build -o /src/blinky.elf -target arduino /src/examples/blinky +``` + +Note that you cannot run `tinygo flash` from inside the docker container, +so it is less useful for microcontroller development. + ## Supported targets The following architectures/systems are currently supported: @@ -120,10 +135,6 @@ Non-goals: crunching. * Be able to compile every Go program out there. -## Building - -See the [installation instructions](https://tinygo.readthedocs.io/en/latest/installation.html). - ## Documentation Documentation is currently maintained on a [dedicated ReadTheDocs diff --git a/docs/docker.rst b/docs/docker.rst new file mode 100644 index 00000000..a11cbb5c --- /dev/null +++ b/docs/docker.rst @@ -0,0 +1,14 @@ +.. docker: + +.. highlight:: none + +Using with Docker +================= + +A docker container exists for easy access to the ``tinygo`` CLI. +For example, to compile the blinky example from the root of the repository:: + + docker run --rm -v $(pwd):/src tinygo/tinygo build -o /src/blinky.elf -target arduino /src/examples/blinky + +Note that you cannot run ``tinygo flash`` from inside the docker container, +so it is less useful for microcontroller development. diff --git a/docs/index.rst b/docs/index.rst index 50bb0618..a755c96f 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -12,6 +12,7 @@ Contents: :maxdepth: 2 installation + docker targets microcontrollers faq