CI related changes.

This commit is contained in:
Orne Brocaar 2022-04-18 21:19:24 +01:00
parent 724fb584f7
commit 8e5d7f760a
10 changed files with 92 additions and 63 deletions

View File

@ -1,4 +1,5 @@
.git
.cargo
**/target
**/node_modules
Dockerfile

View File

@ -14,22 +14,53 @@ jobs:
-
name: Checkout
uses: actions/checkout@v2
-
name: Cargo cache
uses: actions/cache@v3
with:
path: |
.cargo/registry/index/
.cargo/registry/cache/
.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
-
name: Build UI
run: make build-ui
-
name: Run tests
run: make test
docker:
needs: tests
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
chirpstack/${{ github.event.repository.name }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
platforms: linux/amd64
push: ${{ startsWith(github.ref, 'refs/tags/v') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
-
name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

4
.gitignore vendored
View File

@ -20,3 +20,7 @@
# Bitbake recipes
*.bb
# Exclude from gitignore
!/chirpstack/.rpm
!/.github

7
Cargo.lock generated
View File

@ -838,6 +838,7 @@ dependencies = [
"pbjson-types",
"pbkdf2",
"petgraph 0.6.0",
"pq-sys",
"prost",
"prost-types",
"r2d2",
@ -1902,8 +1903,9 @@ dependencies = [
[[package]]
name = "jsonwebtoken"
version = "8.0.1"
source = "git+https://github.com/brocaar/jsonwebtoken.git?branch=fix-issue-190#9679d23195c5c5f93e3cba595c4a582b6ee98d44"
version = "8.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc9051c17f81bae79440afa041b3a278e1de71bfb96d32454b477fd4703ccb6f"
dependencies = [
"base64",
"pem",
@ -2668,6 +2670,7 @@ version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ac25eee5a0582f45a67e837e350d784e7003bd29a5f460796772061ca49ffda"
dependencies = [
"pkg-config",
"vcpkg",
]

View File

@ -1,26 +1,24 @@
FROM rust:1.59.0-alpine as development
FROM chirpstack/chirpstack-dev-cache:latest AS development
ENV PROJECT_PATH=/chirpstack
# See: https://github.com/diesel-rs/diesel/issues/700
ENV RUSTFLAGS="-C target-feature=-crt-static"
RUN apk --no-cache add \
make cmake build-base clang perl protobuf libpq-dev \
nodejs npm yarn
RUN rustup component add rustfmt
RUN mkdir -p $PROJECT_PATH
COPY . $PROJECT_PATH
RUN cd $PROJECT_PATH/ui && yarn install && yarn build
# --network-timeout as yarn throws a ESOCKETTIMEDOUT timeout with GitHub Actions
RUN cd $PROJECT_PATH/ui && \
yarn install --network-timeout 600000 && \
yarn build && \
rm -rf node_modules
RUN cd $PROJECT_PATH/chirpstack && cargo build --release
FROM alpine:3.15.0 as production
FROM debian:buster-slim as production
run apk --no-cache add ca-certificates tzdata libpq
COPY --from=development /chirpstack/target/release/chirpstack /usr/bin/chirpstack
RUN apt-get update && \
apt-get install -y \
ca-certificates \
libpq5 \
&& rm -rf /var/lib/apt/lists/*
COPY --from=development /target/release/chirpstack /usr/bin/chirpstack
COPY --from=development /chirpstack/chirpstack/configuration/* /etc/chirpstack/
USER nobody:nogroup
ENTRYPOINT ["/usr/bin/chirpstack"]

View File

@ -1,6 +1,10 @@
FROM rust:1.59.0-buster
ENV PROJECT_PATH=/chirpstack
ENV CARGO_TARGET_DIR=/target
RUN mkdir -p $PROJECT_PATH
RUN mkdir -p $CARGO_TARGET_DIR
RUN apt-get update && \
apt-get install -y \
@ -10,22 +14,24 @@ RUN apt-get update && \
bash \
screen \
postgresql-client \
libpq-dev \
mosquitto-clients \
redis-tools \
rpm \
clang \
gcc-arm-linux-gnueabi \
g++-arm-linux-gnueabi \
gcc-arm-linux-gnueabihf \
g++-arm-linux-gnueabihf \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu \
&& apt-get clean
yarnpkg \
&& rm -rf /var/lib/apt/lists/*
RUN ln -s /usr/bin/yarnpkg /usr/bin/yarn
RUN rustup component add rustfmt clippy
RUN cargo install diesel_cli --no-default-features --features postgres
RUN cargo install cargo-deb
RUN cargo install cargo-rpm
RUN mkdir -p $PROJECT_PATH
COPY . $PROJECT_PATH
WORKDIR $PROJECT_PATH/chirpstack
RUN cargo build --release
RUN rm -rf $PROJECT_PATH/*

View File

@ -1,10 +1,9 @@
.PHONY: build-development build-release build-ui devshell devshell-ui test test-server update-images
# Builds a debug / development binary.
build-debug: build-ui
build-debug:
docker-compose run --rm chirpstack make debug
build-release: build-ui
# Builds a release binary.
build-release:
docker-compose run --rm chirpstack make release
# Builds the UI.
@ -30,5 +29,5 @@ test-server: build-ui
# Update the Docker development images
update-images:
docker-compose build chirpstack
docker-compose pull chirpstack
docker-compose build chirpstack-ui

View File

@ -27,6 +27,7 @@ diesel_migrations = { version = "1.4" }
r2d2 = "0.8"
bigdecimal = "0.1.2"
redis = { version = "0.21", features = ["r2d2", "cluster"] }
pq-sys = { version = "0.4.6", features = ["pkg-config"] }
# Logging
tracing = "0.1"
@ -79,7 +80,7 @@ anyhow = "1.0"
pbkdf2 = "0.8"
rand_core = { version = "0.6", features = ["std"] }
# jsonwebtoken = "8.0"
jsonwebtoken = { git = "https://github.com/brocaar/jsonwebtoken.git", branch = "fix-issue-190" }
jsonwebtoken = "8.1.0"
openssl = { version = "0.10", features = ["vendored"] }
openidconnect = { version = "2.2.0", features = ["accept-rfc3339-timestamps"] }

View File

@ -6,17 +6,8 @@ debug:
release:
cargo build --release
release-deb-x86-64:
cargo deb --target x86_64-unknown-linux-gnu
release-deb-arm:
cargo deb --target arm-unknown-linux-gnueabi
release-deb-armv7:
cargo deb --garget armv7-unknown-linux-gnueabihf
release-deb-arm64:
cargo deb --target aarch64-unknown-linux-gnu
release-deb:
cargo deb
test:
cargo fmt --check

View File

@ -1,13 +1,8 @@
version: "3"
services:
chirpstack:
build:
context: .
dockerfile: Dockerfile-devel
image: chirpstack/chirpstack-dev-cache:latest
volumes:
- ./:/chirpstack
- ./.cargo/registry:/usr/local/cargo/registry
- ./.cargo/git:/usr/local/cargo/git
depends_on:
- postgres
- redis