File tree 3 files changed +26
-15
lines changed
3 files changed +26
-15
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ LABEL Description="An STS Application"
4
4
5
5
WORKDIR /usr/src
6
6
7
+ RUN apt-get update && apt-get install inotify-tools -y && rm -rf /var/cache/apk/*
8
+
7
9
# Cache this step
8
10
COPY Package.swift /usr/src
9
11
RUN swift package update
@@ -17,4 +19,10 @@ ENV CONFIG=debug
17
19
# user can pass in LIVE=true
18
20
ENV LIVE=false
19
21
22
+ RUN swift build --configuration ${CONFIG}
23
+
24
+ RUN cp ./.build/${CONFIG}/libSTSLibrary.so /usr/lib/libSTSLibrary.so
25
+ RUN cp ./.build/${CONFIG}/STSLibrary.swiftmodule /usr/lib/STSLibrary.swiftmodule
26
+ RUN cp ./.build/${CONFIG}/STSApplication /usr/bin/STSApplication
27
+
20
28
ENTRYPOINT ./entrypoint $CONFIG $LIVE
Original file line number Diff line number Diff line change 2
2
3
3
CONFIG=$1
4
4
LIVE=$2
5
- KILL=false
6
-
7
- handle_interrupt () {
8
- KILL=true
9
- }
10
5
11
6
build () {
12
7
swift build --configuration ${CONFIG}
@@ -27,18 +22,16 @@ build_and_run() {
27
22
}
28
23
29
24
watch_files () {
30
- while [ ${KILL} != true ]
31
- do
32
- files=` find * .swift -type f -newer /usr/bin/STSApplication`
33
- if [[ ${files} != " " ]] ; then
34
- echo " Changes in files: $files , building..."
35
- if [[ ${files} = * " Package.swift" ]] ; then
25
+ inotifywait --quiet --recursive --monitor --event modify --format " %w%f" . \
26
+ | while read file change; do
27
+ if [[ ${file} = * " .swift" ]] ; then
28
+ echo " Changes in file: $file , building..."
29
+ if [[ ${file} = * " Package.swift" ]] ; then
36
30
swift package update
37
31
fi
38
32
build_and_run
39
33
echo " Waiting for changes to run application again."
40
34
fi
41
- sleep 2
42
35
done
43
36
}
44
37
@@ -47,7 +40,7 @@ entrypoint() {
47
40
}
48
41
49
42
live_entrypoint () {
50
- build_and_run
43
+ run_application
51
44
echo " Waiting for changes to run application again."
52
45
watch_files &
53
46
wait
Original file line number Diff line number Diff line change 60
60
STS_BUILD_COMMAND=" docker build -t ${STS_NAME} ."
61
61
fi
62
62
63
- # live flag
63
+ # live flag TODO: Fix conflict edge case with volume and live flags
64
64
if [ " $STS_LIVE_ENABLED " = true ] ; then
65
65
STS_VOLUME_FLAG=" -v $PWD :/usr/src"
66
66
STS_LIVE_FLAG=" -e LIVE=true"
@@ -80,6 +80,9 @@ case ${STS_COMMAND} in
80
80
RUN_COMMAND=" docker run --rm -it ${STS_LIVE_FLAG} ${STS_VOLUME_FLAG} ${STS_NAME} "
81
81
;;
82
82
repl)
83
+ if [ " $STS_LIVE_ENABLED " = true ] ; then
84
+ echo -e " [STS][run][${STS_COMMAND_ARG} ] ignoring unsupported flag: ${TXT_YELLOW} -l|--live${TXT_NC} "
85
+ fi
83
86
RUN_COMMAND=" docker run --rm ${STS_VOLUME_FLAG} --security-opt seccomp:unconfined -it \
84
87
--entrypoint /usr/bin/swift \
85
88
${STS_NAME} \
@@ -91,9 +94,16 @@ case ${STS_COMMAND} in
91
94
-lswiftTensorFlow"
92
95
;;
93
96
test|tests)
94
- RUN_COMMAND=" docker run --rm ${STS_VOLUME_FLAG} --entrypoint " /usr/bin/swift" ${STS_NAME} test"
97
+ # TODO: Finish live reloaded tests; need to think about the --entrypoint usage
98
+ if [ " $STS_LIVE_ENABLED " = true ] ; then
99
+ echo -e " [STS][test][${STS_COMMAND_ARG} ] ignoring unsupported flag: ${TXT_YELLOW} -l|--live${TXT_NC} "
100
+ fi
101
+ RUN_COMMAND=" docker run --rm -it ${STS_LIVE_FLAG} ${STS_VOLUME_FLAG} --entrypoint " /usr/bin/swift" ${STS_NAME} test"
95
102
;;
96
103
xcode)
104
+ if [ " $STS_LIVE_ENABLED " = true ] ; then
105
+ echo -e " [STS][run][${STS_COMMAND_ARG} ] ignoring unsupported flag: ${TXT_YELLOW} -l|--live${TXT_NC} "
106
+ fi
97
107
RUN_COMMAND=" docker run --rm -v ${PWD} :/usr/src \
98
108
--entrypoint /usr/bin/swift \
99
109
${STS_NAME} \
You can’t perform that action at this time.
0 commit comments