2022-07-21 10:00:47 +00:00
|
|
|
# UI build stage
|
2022-12-05 10:00:21 +00:00
|
|
|
FROM --platform=$BUILDPLATFORM alpine:3.17.0 AS ui-build
|
2022-04-06 20:18:32 +00:00
|
|
|
|
2022-05-02 14:10:24 +00:00
|
|
|
ENV PROJECT_PATH=/chirpstack
|
|
|
|
|
|
|
|
RUN apk add --no-cache make git bash build-base nodejs npm yarn
|
|
|
|
|
|
|
|
RUN mkdir -p $PROJECT_PATH
|
|
|
|
COPY ./api/grpc-web $PROJECT_PATH/api/grpc-web
|
|
|
|
COPY ./ui $PROJECT_PATH/ui
|
2022-04-06 20:18:32 +00:00
|
|
|
|
2022-04-18 20:19:24 +00:00
|
|
|
RUN cd $PROJECT_PATH/ui && \
|
2022-07-21 10:00:47 +00:00
|
|
|
yarn install --network-timeout 600000 && \
|
|
|
|
yarn build
|
2022-04-18 20:19:24 +00:00
|
|
|
|
2022-07-21 10:00:47 +00:00
|
|
|
|
|
|
|
# ChirpStack build stage
|
2022-12-05 10:00:21 +00:00
|
|
|
FROM --platform=$BUILDPLATFORM rust:1.65.0-buster AS rust-build
|
2022-07-21 10:00:47 +00:00
|
|
|
|
|
|
|
ENV PROJECT_PATH=/chirpstack
|
|
|
|
RUN mkdir -p $PROJECT_PATH
|
|
|
|
|
|
|
|
RUN dpkg --add-architecture armhf
|
|
|
|
RUN dpkg --add-architecture arm64
|
|
|
|
|
|
|
|
RUN apt-get update && \
|
|
|
|
apt-get install -y \
|
|
|
|
make \
|
|
|
|
cmake \
|
|
|
|
git \
|
|
|
|
libpq-dev \
|
|
|
|
clang \
|
2022-07-27 11:00:11 +00:00
|
|
|
libclang-dev \
|
2022-07-21 10:00:47 +00:00
|
|
|
jq \
|
2022-09-26 11:58:01 +00:00
|
|
|
protobuf-compiler \
|
2022-07-21 10:00:47 +00:00
|
|
|
gcc-arm-linux-gnueabihf \
|
|
|
|
g++-arm-linux-gnueabihf \
|
|
|
|
gcc-aarch64-linux-gnu \
|
|
|
|
g++-aarch64-linux-gnu \
|
|
|
|
zlib1g-dev:armhf \
|
|
|
|
zlib1g-dev:arm64
|
|
|
|
|
|
|
|
RUN rustup target add armv7-unknown-linux-gnueabihf
|
|
|
|
RUN rustup target add aarch64-unknown-linux-gnu
|
|
|
|
|
|
|
|
ARG TARGETPLATFORM
|
|
|
|
RUN mkdir -p /release/$TARGETPLATFORM
|
2022-05-02 14:10:24 +00:00
|
|
|
|
|
|
|
COPY . $PROJECT_PATH
|
|
|
|
COPY --from=ui-build $PROJECT_PATH/ui/build $PROJECT_PATH/ui/build
|
2022-04-06 20:18:32 +00:00
|
|
|
|
2022-07-21 10:00:47 +00:00
|
|
|
RUN case "$TARGETPLATFORM" in \
|
|
|
|
"linux/amd64") \
|
|
|
|
cd $PROJECT_PATH/chirpstack && make release-amd64; \
|
|
|
|
cp $PROJECT_PATH/target/release/chirpstack /release/$TARGETPLATFORM; \
|
|
|
|
;; \
|
|
|
|
"linux/arm/v7") \
|
|
|
|
cd $PROJECT_PATH/chirpstack && make release-armv7hf; \
|
|
|
|
cp $PROJECT_PATH/target/armv7-unknown-linux-gnueabihf/release/chirpstack /release/$TARGETPLATFORM; \
|
|
|
|
;; \
|
|
|
|
"linux/arm64") \
|
|
|
|
cd $PROJECT_PATH/chirpstack && make release-arm64; \
|
|
|
|
cp $PROJECT_PATH/target/aarch64-unknown-linux-gnu/release/chirpstack /release/$TARGETPLATFORM; \
|
|
|
|
;; \
|
|
|
|
esac;
|
|
|
|
|
|
|
|
|
|
|
|
# Final stage
|
2022-04-18 20:19:24 +00:00
|
|
|
FROM debian:buster-slim as production
|
|
|
|
|
|
|
|
RUN apt-get update && \
|
|
|
|
apt-get install -y \
|
|
|
|
ca-certificates \
|
|
|
|
libpq5 \
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
2022-04-06 20:18:32 +00:00
|
|
|
|
2022-07-21 10:00:47 +00:00
|
|
|
ARG TARGETPLATFORM
|
|
|
|
|
|
|
|
COPY --from=rust-build /release/$TARGETPLATFORM/chirpstack /usr/bin/chirpstack
|
2022-05-02 14:10:24 +00:00
|
|
|
COPY --from=rust-build /chirpstack/chirpstack/configuration/* /etc/chirpstack/
|
2022-04-06 20:18:32 +00:00
|
|
|
USER nobody:nogroup
|
|
|
|
ENTRYPOINT ["/usr/bin/chirpstack"]
|