-
Notifications
You must be signed in to change notification settings - Fork 92
/
Dockerfile
81 lines (68 loc) · 2.51 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# MTConnect Public C++ Agent Docker image build instructions
# ---------------------------------------------------------------------
# notes
# ---------------------------------------------------------------------
#
# to build a cross-platform image, push to docker hub, and run it -
# (see CMakeLists.txt for current version number) -
#
# docker buildx build \
# --platform linux/amd64,linux/arm64 \
# --tag mtconnect/demo:latest \
# --push \
# -f demo/Dockerfile
# .
#
# To run tests, use `--build-arg WITH_TESTS=true`
#
# docker run -it --rm --init --name agent -p5000:5000 mtconnect/demo
#
# then visit http://localhost:5000 to see the demo output.
# ---------------------------------------------------------------------
# Use the mtconnect/agent base image
# ---------------------------------------------------------------------
FROM mtconnect/agent as mtconnect
LABEL author='mtconnect' description='MTConnect C++ Agent Demo'
USER root
RUN apk --update add ruby
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
# 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/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/bin
# |-- agent - the cppagent application
#
# /mtconnect/config - Configuration files agent.cfg and Devices.xml
#
# /mtconnect/data
# |-- schemas - xsd files
# |-- styles - styles.xsl, styles.css, favicon.ico, etc
#
# /home/agent - the user's directory
#
# /mtconnect/log - logging directory