Skip to content

Commit

Permalink
Merge pull request #42 from CDOT-CV/develop
Browse files Browse the repository at this point in the history
Transition to J2735 ASN 2020, Dockerfile Optimization & Updated SCMS Files
  • Loading branch information
dan-du-car authored Feb 2, 2024
2 parents c9df9db + 64489b2 commit 5b2b420
Show file tree
Hide file tree
Showing 49 changed files with 4,776 additions and 5,918 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,13 @@ jobs:
path: /home/runner/work/asn1-codec/asn1-codec/bw-output
# Archive build-wrapper output

- name: Setup SonarScanner
uses: warchant/setup-sonar-scanner@v4
- uses: actions/setup-java@v3
with:
version: 4.8.0.2856
# Set up SonarScanner for code analysis
distribution: 'temurin'
java-version: '17'

- name: Setup SonarScanner
uses: warchant/setup-sonar-scanner@v7

- name: Generate sonar properties file
run: |
Expand Down
9 changes: 3 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[submodule "asn1c"]
path = asn1c
url = https://github.com/vlm/asn1c.git
[submodule "pugixml"]
path = pugixml
url = https://github.com/zeux/pugixml.git
[submodule "scms-asn1"]
path = scms-asn1
url = https://github.com/usdot-jpo-ode/scms-asn1.git
[submodule "asn1c"]
path = asn1c
url = https://github.com/mouse07410/asn1c
67 changes: 42 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,50 +1,54 @@
FROM ubuntu:18.04
# === BUILDER IMAGE ===
FROM alpine:3.12 as builder
USER root

WORKDIR /asn1_codec

VOLUME ["/asn1_codec_share"]

# Add build tools.
RUN apt-get update && apt-get install -y software-properties-common wget git make gcc-7 g++-7 gcc-7-base && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 100 && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 100

# Install cmake.
RUN apt-get install -y cmake

# install libtool and automake
RUN apt-get install -y automake libtool

# Install librdkafka.
RUN apt-get install -y sudo
RUN wget -qO - https://packages.confluent.io/deb/7.3/archive.key | sudo apt-key add -
RUN add-apt-repository "deb [arch=amd64] https://packages.confluent.io/deb/7.3 stable main"
RUN add-apt-repository "deb https://packages.confluent.io/clients/deb $(lsb_release -cs) main"
RUN apt update
RUN apt-get install -y libsasl2-modules libsasl2-modules-gssapi-mit libsasl2-dev libssl-dev
RUN apt install -y librdkafka-dev
# add build dependencies
RUN apk add --upgrade --no-cache --virtual .build-deps \
cmake \
g++ \
make \
bash \
automake \
libtool \
autoconf \
librdkafka \
librdkafka-dev \
flex \
bison

# Install pugixml
ADD ./pugixml /asn1_codec/pugixml
RUN cd /asn1_codec/pugixml && mkdir -p build && cd build && cmake .. && make && make install

# Build and install asn1c submodule
ADD ./asn1c /asn1_codec/asn1c
RUN cd /asn1_codec/asn1c && aclocal && test -f configure || autoreconf -iv && ./configure && make && make install
RUN cd asn1c && test -f configure || autoreconf -iv && ./configure && make && make install

# Generate ASN.1 API.
# Make generated files available to the build & compile example
RUN export LD_LIBRARY_PATH=/usr/local/lib
ADD ./asn1c_combined /asn1_codec/asn1c_combined
ADD ./scms-asn1 /asn1_codec/scms-asn1
RUN cd /asn1_codec/asn1c_combined && bash doIt.sh

# Remove any lingering .asn files
RUN rm -rf /asn1c_codec/asn1c_combined/j2735-asn-files
RUN rm -rf /asn1c_codec/asn1c_combined/semi-asn-files
RUN rm -rf /asn1c_codec/asn1c_combined/scms-asn-files

# Remove duplicate files
RUN rm -rf /asn1c_codec/asn1c_combined/generated-files

# add the source and build files
ADD CMakeLists.txt /asn1_codec
ADD ./config /asn1_codec/config
ADD ./include /asn1_codec/include
ADD ./src /asn1_codec/src
ADD ./kafka-test /asn1_codec/kafka-test
ADD ./unit-test-data /asn1_codec/unit-test-data
ADD ./data /asn1_codec/data
ADD ./run_acm.sh /asn1_codec
ADD ./data /asn1_codec/data

RUN echo "export LD_LIBRARY_PATH=/usr/local/lib" >> ~/.profile
RUN echo "export LD_LIBRARY_PATH=/usr/local/lib" >> ~/.bashrc
Expand All @@ -54,8 +58,21 @@ RUN echo "export CC=gcc" >> ~/.bashrc
# Build acm.
RUN mkdir -p /build && cd /build && cmake /asn1_codec && make

# Add test data. This changes frequently so keep it low in the file.
ADD ./docker-test /asn1_codec/docker-test
# === RUNTIME IMAGE ===
FROM alpine:3.12
USER root
WORKDIR /asn1_codec
VOLUME ["/asn1_codec_share"]

# add runtime dependencies
RUN apk add --upgrade --no-cache \
bash \
librdkafka \
librdkafka-dev

# copy the built files from the builder
COPY --from=builder /asn1_codec /asn1_codec
COPY --from=builder /build /build

# run ACM
RUN chmod 7777 /asn1_codec/run_acm.sh
Expand Down
73 changes: 45 additions & 28 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,55 +1,53 @@
FROM ubuntu:18.04
# === BUILDER IMAGE ===
FROM alpine:3.12 as builder
USER root

WORKDIR /asn1_codec

VOLUME ["/asn1_codec_share"]

# Add build tools.
RUN apt-get update && apt-get install -y software-properties-common wget git make gcc-7 g++-7 gcc-7-base && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 100 && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 100

#install editors vim and nano
RUN apt-get update && apt-get install -y vim
RUN apt-get update && apt-get install -y nano

# Install cmake.
RUN wget https://cmake.org/files/v3.7/cmake-3.7.2.tar.gz && tar -xvf cmake-3.7.2.tar.gz
RUN cd cmake-3.7.2 && ./bootstrap && make && make install && cd /home

# install libtool and automake
RUN apt-get update && apt-get install -y automake libtool

# Install librdkafka.
RUN apt-get install -y sudo
RUN wget -qO - https://packages.confluent.io/deb/7.3/archive.key | sudo apt-key add -
RUN add-apt-repository "deb [arch=amd64] https://packages.confluent.io/deb/7.3 stable main"
RUN add-apt-repository "deb https://packages.confluent.io/clients/deb $(lsb_release -cs) main"
RUN apt update
RUN apt-get install -y libsasl2-modules libsasl2-modules-gssapi-mit libsasl2-dev libssl-dev
RUN apt install -y librdkafka-dev
# add build dependencies
RUN apk add --upgrade --no-cache --virtual .build-deps \
cmake \
g++ \
make \
bash \
automake \
libtool \
autoconf \
librdkafka \
librdkafka-dev \
flex \
bison

# Install pugixml
ADD ./pugixml /asn1_codec/pugixml
RUN cd /asn1_codec/pugixml && mkdir -p build && cd build && cmake .. && make && make install

# Build and install asn1c submodule
ADD ./asn1c /asn1_codec/asn1c
RUN cd /asn1_codec/asn1c && aclocal && test -f configure || autoreconf -iv && ./configure && make && make install
RUN cd asn1c && test -f configure || autoreconf -iv && ./configure && make && make install

# Generate ASN.1 API.
# Make generated files available to the build & compile example
RUN export LD_LIBRARY_PATH=/usr/local/lib
ADD ./asn1c_combined /asn1_codec/asn1c_combined
ADD ./scms-asn1 /asn1_codec/scms-asn1
RUN cd /asn1_codec/asn1c_combined && bash doIt.sh

# Remove any lingering .asn files
RUN rm -rf /asn1c_codec/asn1c_combined/j2735-asn-files
RUN rm -rf /asn1c_codec/asn1c_combined/semi-asn-files

# Remove duplicate files
RUN rm -rf /asn1c_codec/asn1c_combined/generated-files

# add the source and build files
ADD CMakeLists.txt /asn1_codec
ADD ./config /asn1_codec/config
ADD ./include /asn1_codec/include
ADD ./src /asn1_codec/src
ADD ./kafka-test /asn1_codec/kafka-test
ADD ./unit-test-data /asn1_codec/unit-test-data
ADD ./data /asn1_codec/data
ADD ./run_acm.sh /asn1_codec
ADD ./data /asn1_codec/data

RUN echo "export LD_LIBRARY_PATH=/usr/local/lib" >> ~/.profile
RUN echo "export LD_LIBRARY_PATH=/usr/local/lib" >> ~/.bashrc
Expand All @@ -59,6 +57,25 @@ RUN echo "export CC=gcc" >> ~/.bashrc
# Build acm.
RUN mkdir -p /build && cd /build && cmake /asn1_codec && make

# === RUNTIME IMAGE ===
FROM alpine:3.12
USER root
WORKDIR /asn1_codec
VOLUME ["/asn1_codec_share"]

# add runtime dependencies
RUN apk add --upgrade --no-cache \
bash \
librdkafka \
librdkafka-dev

# install editors vim and nano
RUN apk update && apk add vim nano

# copy the built files from the builder
COPY --from=builder /asn1_codec /asn1_codec
COPY --from=builder /build /build

# Add test data. This changes frequently so keep it low in the file.
ADD ./docker-test /asn1_codec/docker-test

Expand Down
64 changes: 41 additions & 23 deletions Dockerfile.standalone
Original file line number Diff line number Diff line change
@@ -1,52 +1,70 @@
FROM ubuntu:18.04
# === BUILDER IMAGE ===
FROM alpine:3.12 as builder
USER root

WORKDIR /asn1_codec

# Add build tools.
RUN apt-get update && apt-get install -y software-properties-common wget git make gcc-7 g++-7 gcc-7-base && update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 100 && update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 100

# Install cmake.
RUN wget https://cmake.org/files/v3.7/cmake-3.7.2.tar.gz && tar -xvf cmake-3.7.2.tar.gz
RUN cd cmake-3.7.2 && ./bootstrap && make && make install && cd /home

# install libtool and automake
RUN apt-get update && apt-get install -y automake libtool

# Install librdkafka.
RUN apt-get install -y sudo
RUN wget -qO - https://packages.confluent.io/deb/7.3/archive.key | sudo apt-key add -
RUN add-apt-repository "deb [arch=amd64] https://packages.confluent.io/deb/7.3 stable main"
RUN add-apt-repository "deb https://packages.confluent.io/clients/deb $(lsb_release -cs) main"
RUN apt update
RUN apt-get install -y libsasl2-modules libsasl2-modules-gssapi-mit libsasl2-dev libssl-dev
RUN apt install -y librdkafka-dev
# add build dependencies
RUN apk add --upgrade --no-cache --virtual .build-deps \
cmake \
g++ \
make \
bash \
automake \
libtool \
autoconf \
librdkafka \
librdkafka-dev \
flex \
bison

# Install pugixml
ADD ./pugixml /asn1_codec/pugixml
RUN cd /asn1_codec/pugixml && mkdir -p build && cd build && cmake .. && make && make install

# Build and install asn1c submodule
ADD ./asn1c /asn1_codec/asn1c
RUN cd /asn1_codec/asn1c && aclocal && test -f configure || autoreconf -iv && ./configure && make && make install
RUN cd asn1c && test -f configure || autoreconf -iv && ./configure && make && make install

# Generate ASN.1 API.
# Make generated files available to the build & compile example
RUN export LD_LIBRARY_PATH=/usr/local/lib
ADD ./asn1c_combined /asn1_codec/asn1c_combined
ADD ./scms-asn1 /asn1_codec/scms-asn1
RUN cd /asn1_codec/asn1c_combined && bash doIt.sh

# Remove any lingering .asn files
RUN rm -rf /asn1c_codec/asn1c_combined/j2735-asn-files
RUN rm -rf /asn1c_codec/asn1c_combined/semi-asn-files

# Remove duplicate files
RUN rm -rf /asn1c_codec/asn1c_combined/generated-files

# add the source and build files
ADD CMakeLists.txt /asn1_codec
ADD ./config /asn1_codec/config
ADD ./include /asn1_codec/include
ADD ./src /asn1_codec/src
ADD ./kafka-test /asn1_codec/kafka-test
ADD ./unit-test-data /asn1_codec/unit-test-data
ADD ./data /asn1_codec/data
ADD ./run_acm.sh /asn1_codec
ADD ./data /asn1_codec/data

# Build acm.
RUN mkdir -p /build && cd /build && cmake /asn1_codec && make

# === RUNTIME IMAGE ===
FROM alpine:3.12
USER root
WORKDIR /asn1_codec

# add runtime dependencies
RUN apk add --upgrade --no-cache \
bash \
librdkafka \
librdkafka-dev

# copy the built files from the builder
COPY --from=builder /asn1_codec /asn1_codec
COPY --from=builder /build /build

# Add test data. This changes frequently so keep it low in the file.
ADD ./docker-test /asn1_codec/docker-test
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,8 @@ There is a provided docker-compose file (docker-compose-confluent-cloud.yml) tha

## Note
This has only been tested with Confluent Cloud but technically all SASL authenticated Kafka brokers can be reached using this method.

# Generating C Files from ASN.1 Definitions
Check here for instructions on how to generate C files from ASN.1 definitions: [ASN.1 C File Generation](asn1c_combined/README.md)

This should only be necessary if the ASN.1 definitions change. The generated files are already included in the repository.
2 changes: 1 addition & 1 deletion asn1c
Submodule asn1c updated 844 files
8 changes: 4 additions & 4 deletions asn1c_combined/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*.c
*.h
*.o
Makefile*
./*.c
./*.h
./*.o
./Makefile*

Loading

0 comments on commit 5b2b420

Please sign in to comment.