Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2.3 deviceType rest interface parameter #356

Merged
merged 41 commits into from
Nov 3, 2023
Merged
Changes from 10 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
1a65154
initial device type rest argument
wsobel Oct 5, 2023
a41377a
Version 2.2.0.8 – fixed boundry race condition between replay of samp…
wsobel Oct 6, 2023
4c982e3
Merge pull request #336 from mtconnect/period-filter-round-2
wsobel Oct 6, 2023
89a18d7
Fixed agent id
wsobel Oct 13, 2023
6c893d9
added agent device uuid test. version 2.2.0.9
wsobel Oct 16, 2023
79e8be5
Merge pull request #341 from mtconnect/fixed_agent_uuid
wsobel Oct 17, 2023
546d44b
Change mqtt sink to support device topic and probe topic as aliases. …
wsobel Oct 17, 2023
a3d76bb
Merge branch 'main' into device_topic_for_mqtt_sink_2
wsobel Oct 17, 2023
777f4de
Merge pull request #346 from mtconnect/device_topic_for_mqtt_sink_2
wsobel Oct 17, 2023
1eeac02
docker workflow updates
wsobel Oct 18, 2023
f130664
Added matrix for multiple docker image builds
wsobel Oct 18, 2023
91f5eb1
build all dependencies from source
wsobel Oct 18, 2023
ea89b71
limit build to one docker image for now
wsobel Oct 18, 2023
0d34aee
Added cmake build from source for cross compilation
wsobel Oct 18, 2023
a2252b5
Use system version of tools if available
wsobel Oct 18, 2023
4030d83
Fixed crash on out of range streaming from. Added mosquitto configura…
wsobel Oct 19, 2023
c3e2aa3
fixed windows cmake check
wsobel Oct 19, 2023
aad5f11
Added gallon and pint conversions for gps to lps
wsobel Oct 19, 2023
c4d61f4
Added spec tests for streaming sample out of range. Started added dox…
wsobel Oct 19, 2023
cb8e6ae
Update agent schema files to match schemas repo
wsobel Oct 19, 2023
cd0abd5
Merge pull request #349 from mtconnect/docker_image_workflow_builds
wsobel Oct 19, 2023
9e8439f
Added Heartbeat to the SHDR adapter to override
wsobel Oct 19, 2023
784f8aa
Only trigger docker workflow on push of tags
wsobel Oct 19, 2023
97007e3
Fixed issue with publishing conditions without state
wsobel Oct 19, 2023
89cb69a
Reduced image size for demo and builds
wsobel Oct 20, 2023
5199e27
Merge pull request #352 from mtconnect/fix_mqtt_service_condition_han…
wsobel Oct 20, 2023
afa2294
Merge branch 'main' into add_adapter_configuration_to_override_ping_rate
wsobel Oct 20, 2023
7d1b2cc
Merge branch 'main' into reduce_docker_image_size
wsobel Oct 20, 2023
3b25761
Update Dockerfile
wsobel Oct 20, 2023
1a2de47
Merge pull request #351 from mtconnect/add_adapter_configuration_to_o…
wsobel Oct 20, 2023
72fdbda
Fixes to the dockerfiles
wsobel Oct 20, 2023
fbbe38e
Base demo on the dockerhub mtconnect/agent image
wsobel Oct 20, 2023
8052c2f
Merge branch 'main' into reduce_docker_image_size
wsobel Oct 20, 2023
0d4626a
Updated workflow to build demo dockerfile. Changed replicator to use …
wsobel Oct 20, 2023
8896bdc
Changed compose demos to use mtconnect/agent image
wsobel Oct 20, 2023
57d432e
Fixed race condition in file cache and async observer under load
wsobel Oct 21, 2023
d3eec2c
Merge pull request #353 from mtconnect/reduce_docker_image_size
wsobel Oct 21, 2023
0d966f5
Merge branch 'main' into version-2.3-device-type-rest-interface
wsobel Oct 22, 2023
eb15f9f
added deviceType and tests
wsobel Oct 22, 2023
2742c25
Version 2.3.0.0 RC 1
wsobel Oct 22, 2023
02adeeb
Merge branch 'main-dev' into version-2.3-device-type-rest-interface
wsobel Oct 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
@@ -35,11 +35,12 @@ jobs:
# the type of runner that the job will run on
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
include:
include:
- dockerfile: docker/alpine/Dockerfile
name: agent
- dockerfile: demo/Dockerfile.alpine
- dockerfile: demo/Dockerfile
name: demo

# steps represent a sequence of tasks that will be executed as part of the job
@@ -63,7 +64,11 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}


- name: Remove leading v from the version
run: |
echo "VERSION=$(echo ${{ github.ref_name }} | sed 's/^v//')" >> $GITHUB_ENV

# see https://github.com/docker/build-push-action
- name: Build image and push to DockerHub
uses: docker/build-push-action@v5
@@ -75,7 +80,7 @@ jobs:
# docker hub user/repo:tag
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.name }}:latest
${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.name }}:${{ github.ref_name }}
${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.name }}:${{ env.VERSION }}

# push to docker hub
push: true
176 changes: 29 additions & 147 deletions demo/Dockerfile
Original file line number Diff line number Diff line change
@@ -10,193 +10,75 @@
#
# docker buildx build \
# --platform linux/amd64,linux/arm64 \
# --tag mtconnect/agent:2.0.0.12_RC18 \
# --tag mtconnect/demo:latest \
# --push \
# -f demo/Dockerfile
# .
#
# To run tests, use `--build-arg WITH_TESTS=true`
#
# # Note: In this case, I would suggest to map port `5000` to `5000`. The user can always change the port according to their needs.
# docker run -it --rm --init --name agent -p5000:5000 \
# mtconnect/agent:2.0.0.12_RC18
# docker run -it --rm --init --name agent -p5000:5000 mtconnect/demo
#
# then visit http://localhost:5000 to see the demo output.

# ---------------------------------------------------------------------
# os
# Use the mtconnect/agent base image
# ---------------------------------------------------------------------

# base image - ubuntu has amd64, arm64 etc.
# 22.04 is the current long term support release, maintained until 2025-04.
FROM ubuntu:22.04 AS os

# tzinfo hangs without this
ARG DEBIAN_FRONTEND='noninteractive'

# ---------------------------------------------------------------------
# build
# ---------------------------------------------------------------------

FROM os AS build

# limit cpus so don't run out of memory on local machine
# symptom: get error - "c++: fatal error: Killed signal terminated program cc1plus"
# can turn off if building in cloud
ARG CONAN_CPU_COUNT=2

ARG WITH_RUBY='True'

# set some variables
ENV PATH="$HOME/venv3.9/bin:$PATH"
ENV CONAN_PROFILE='conan/profiles/docker'

# update os and add dependencies
# note: Dockerfiles run as root by default, so don't need sudo
RUN apt-get update \
&& apt-get install -y \
autoconf \
automake \
build-essential \
cmake \
git \
python3 \
python3-pip \
rake \
ruby \
&& rm -rf /var/lib/apt/lists/* \
&& pip install conan -v 'conan==2.0.9'

# make an agent directory and cd into it
WORKDIR /root/agent

# bring in the repo contents, minus .dockerignore files
COPY . .

ARG WITH_TESTS=false
ARG WITH_TESTS_ARG=argument
ARG SHARED=False

# Build and optionally test
RUN if [ -z "$WITH_TESTS" ] || [ "$WITH_TESTS" = "false" ]; then \
WITH_TESTS_ARG="--test-folder="; \
else \
WITH_TESTS_ARG=""; \
fi \
&& conan profile detect \
&& conan create . \
--build=missing \
-c "tools.build:jobs=$CONAN_CPU_COUNT" \
-o agent_prefix=mtc \
-o cpack=True \
-o "with_ruby=$WITH_RUBY" \
-o cpack_destination=/root/agent \
-o cpack_name=dist \
-o cpack_generator=TGZ \
-pr "$CONAN_PROFILE" \
${WITH_TESTS_ARG}

# ---------------------------------------------------------------------
# release
# ---------------------------------------------------------------------

FROM os AS release
FROM mtconnect/agent as mtconnect

# TODO: How about shortening the description to MTConnect Agent or at least MTConnect C++ Agent?
LABEL author='mtconnect' description='MTConnect C++ Agent'

ARG BIN_DIR='/usr/local/bin'
ARG LIB_DIR='/usr/local/lib'

ARG MTCONNECT_CONF_DIR='/etc/mtconnect'
ARG MTCONNECT_DATA_DIR='/usr/local/share/mtconnect'
ARG MTCONNECT_LOG_DIR='/var/log/mtconnect'
LABEL author='mtconnect' description='MTConnect C++ Agent Demo'

ENV MTCONNECT_CONF_DIR="$MTCONNECT_CONF_DIR"
ENV MTCONNECT_DATA_DIR="$MTCONNECT_DATA_DIR"
ENV MTCONNECT_LOG_DIR="$MTCONNECT_LOG_DIR"
ENV DEMO_DIR="$MTCONNECT_DATA_DIR/demo"

# install ruby for simulator
RUN apt-get update \
&& apt-get install -y ruby
USER root

# change to a new non-root user for better security.
# this also adds the user to a group with the same name.
# -m creates a home folder, ie /home/<username>
ARG UID=1000
ARG GID=1000
RUN apk add ruby

RUN groupadd \
--gid $GID \
agent \
&& useradd \
--create-home \
--uid $UID \
--gid $GID \
agent
COPY --chown=agent:agent \
./simulator/* \
/mtconnect/data/simulator/
COPY --chown=agent:agent \
./demo/ \
/mtconnect/data/demo/
COPY --chown=agent:agent \
./demo/agent/agent.dock \
./demo/agent/Devices.xml \
/mtconnect/config/

USER agent
WORKDIR /home/agent

# install agent executable
COPY --chown=agent:agent --from=build /root/agent/dist.tar.gz /home/agent/

# Extract the data
RUN tar xf dist.tar.gz \
&& rm dist.tar.gz

# Copy the agent binary and create folders used by the agent
USER root
RUN mkdir -p "$BIN_DIR" "$LIB_DIR" \
&& cp /home/agent/dist/bin/* "$BIN_DIR" \
&& cp /home/agent/dist/lib/* "$LIB_DIR" \
&& mkdir -p "$MTCONNECT_CONF_DIR" \
"$MTCONNECT_DATA_DIR" \
"$MTCONNECT_LOG_DIR" \
&& chown agent:agent "$MTCONNECT_CONF_DIR" \
"$MTCONNECT_DATA_DIR" \
"$MTCONNECT_LOG_DIR"

USER agent

# Copy the agent data
RUN cp -r /home/agent/dist/share/mtconnect/schemas \
/home/agent/dist/share/mtconnect/simulator \
/home/agent/dist/share/mtconnect/styles \
/home/agent/dist/share/mtconnect/demo \
"$MTCONNECT_DATA_DIR" \
&& cp /home/agent/dist/share/mtconnect/demo/agent/agent.dock "$MTCONNECT_CONF_DIR/agent.cfg" \
&& cp /home/agent/dist/share/mtconnect/demo/agent/Devices.xml "$MTCONNECT_CONF_DIR" \
&& rm -r /home/agent/dist

# expose port
EXPOSE 5000

# Allow the directories to be mounted
VOLUME ["/mtconnect/config", "/mtconnect/log", "/mtconnect/data"]

# default command - can override with docker run or docker-compose command.
# this runs the adapter simulator and the agent using the sample config file.
# note: must use shell form here instead of exec form, since we're running
# multiple statements using shell commands (& and &&).
# see https://stackoverflow.com/questions/46797348/docker-cmd-exec-form-for-multiple-command-execution
CMD /usr/bin/ruby "$MTCONNECT_DATA_DIR/simulator/run_scenario.rb" -p 7879 -l "$DEMO_DIR/agent/mazak.txt" \
& /usr/bin/ruby "$MTCONNECT_DATA_DIR/simulator/run_scenario.rb" -p 7878 -l "$DEMO_DIR/agent/okuma.txt" \
& mtcagent run

CMD /usr/bin/ruby /mtconnect/data/simulator/run_scenario.rb -p 7879 -l /mtconnect/data/demo/agent/mazak.txt \
& /usr/bin/ruby /mtconnect/data/simulator/run_scenario.rb -p 7878 -l /mtconnect/data/demo/agent/okuma.txt \
& mtcagent run /mtconnect/config/agent.dock

# ---------------------------------------------------------------------
# note
# ---------------------------------------------------------------------

# after setup, the dirs look like this -
#
# /usr/local/bin
# /usr/bin
# |-- agent - the cppagent application
#
# /etc/mtconnect - Configuration files agent.cfg and Devices.xml
# /mtconnect/config - Configuration files agent.cfg and Devices.xml
#
# /usr/local/share/mtconnect
# /mtconnect/data
# |-- schemas - xsd files
# |-- simulator - agent.cfg, simulator.rb, vmc-3axis.xml, log.txt
# |-- styles - styles.xsl, styles.css, favicon.ico, etc
#
# /home/agent - the user's directory
#
# /var/log/mtconnect - logging directory
# /mtconnect/log - logging directory
Loading