feat(docker): add one-command Dockerfile
This adds a simple Dockerfile for anyone to just `docker build .` and get a Docker image. This Dockerfile is optimized for human consumption, not for build performance.pull/24376/head
parent
a3fa788d6a
commit
485024cb5b
|
@ -0,0 +1,51 @@
|
|||
#syntax=docker/dockerfile:1.2
|
||||
FROM rust:slim-buster AS build
|
||||
|
||||
# Build flatbuffers, a dependency of influxdb_iox
|
||||
ARG flatbuffers_version="v1.12.0"
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y \
|
||||
git make clang cmake llvm libssl-dev pkg-config \
|
||||
--no-install-recommends \
|
||||
&& git clone -b ${flatbuffers_version} -- https://github.com/google/flatbuffers.git /usr/local/src/flatbuffers \
|
||||
&& cmake -S /usr/local/src/flatbuffers -B /usr/local/src/flatbuffers \
|
||||
-G "Unix Makefiles" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
&& make -C /usr/local/src/flatbuffers -j $(nproc) flatc \
|
||||
&& ln /usr/local/src/flatbuffers/flatc /usr/bin/flatc
|
||||
|
||||
# Build influxdb_iox
|
||||
COPY . /influxdb_iox
|
||||
WORKDIR /influxdb_iox
|
||||
RUN \
|
||||
--mount=type=cache,id=influxdb_iox_rustup,sharing=locked,target=/usr/local/rustup \
|
||||
rustup component add rustfmt
|
||||
RUN \
|
||||
--mount=type=cache,id=influxdb_iox_rustup,sharing=locked,target=/usr/local/rustup \
|
||||
--mount=type=cache,id=influxdb_iox_registry,sharing=locked,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,id=influxdb_iox_git,sharing=locked,target=/usr/local/cargo/git \
|
||||
--mount=type=cache,id=influxdb_iox_target,sharing=locked,target=/influxdb_iox/target \
|
||||
du -cshx /usr/local/rustup /usr/local/cargo/registry /usr/local/cargo/git /influxdb_iox/target && \
|
||||
cargo build --target-dir /influxdb_iox/target --release && \
|
||||
cp /influxdb_iox/target/release/influxdb_iox /root/influxdb_iox && \
|
||||
du -cshx /usr/local/rustup /usr/local/cargo/registry /usr/local/cargo/git /influxdb_iox/target
|
||||
|
||||
FROM debian:buster-slim
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y libssl1.1 libgcc1 libc6 --no-install-recommends \
|
||||
&& rm -rf /var/lib/{apt,dpkg,cache,log}
|
||||
|
||||
RUN groupadd -g 1500 rust \
|
||||
&& useradd -u 1500 -g rust -s /bin/bash -m rust
|
||||
|
||||
USER rust
|
||||
|
||||
RUN mkdir ~/.influxdb_iox
|
||||
RUN ls -la ~/.influxdb_iox
|
||||
|
||||
COPY --from=build /root/influxdb_iox /usr/bin/influxdb_iox
|
||||
|
||||
EXPOSE 8080 8082
|
||||
|
||||
ENTRYPOINT ["/usr/bin/influxdb_iox"]
|
|
@ -0,0 +1,4 @@
|
|||
.*/
|
||||
target/
|
||||
tests/
|
||||
docker/
|
12
README.md
12
README.md
|
@ -31,6 +31,18 @@ We're also hosting monthly tech talks and community office hours on the project
|
|||
To compile and run InfluxDB IOx from source, you'll need a Rust compiler and a `flatc` FlatBuffers
|
||||
compiler.
|
||||
|
||||
### Build a Docker Image
|
||||
|
||||
To build a Docker image in one command:
|
||||
```
|
||||
docker build .
|
||||
```
|
||||
|
||||
To enable caching, and to respect `Dockerfile.dockerignore`, we strongly suggest that you [enable BuildKit](https://docs.docker.com/develop/develop-images/build_enhancements/#to-enable-buildkit-builds).
|
||||
- Use Docker version 18.09 or later
|
||||
- Enable BuildKit by default by setting `{ "features": { "buildkit": true } }`
|
||||
- ...or run `docker build .` with env var `DOCKER_BUILDKIT=1`
|
||||
|
||||
### Cloning the Repository
|
||||
|
||||
Using `git`, check out the code by cloning this repository. If you use the `git` command line, this
|
||||
|
|
|
@ -12,12 +12,13 @@
|
|||
# Build any binaries that can be copied into the CI image
|
||||
# Note we build flatbuffers from source (pinned to a particualar version)
|
||||
FROM rust:slim-buster AS flatc
|
||||
ARG flatbuffers_version="v1.12.0"
|
||||
RUN apt-get update \
|
||||
&& mkdir -p /usr/share/man/man1 \
|
||||
&& apt-get install -y \
|
||||
git make clang cmake llvm \
|
||||
--no-install-recommends \
|
||||
&& git clone -b v1.12.0 -- https://github.com/google/flatbuffers.git /usr/local/src/flatbuffers \
|
||||
&& git clone -b ${flatbuffers_version} -- https://github.com/google/flatbuffers.git /usr/local/src/flatbuffers \
|
||||
&& cmake -S /usr/local/src/flatbuffers -B /usr/local/src/flatbuffers \
|
||||
-G "Unix Makefiles" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
# Ignore everything
|
||||
**
|
Loading…
Reference in New Issue