File tree Expand file tree Collapse file tree 3 files changed +26
-15
lines changed
Expand file tree Collapse file tree 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"
44
55WORKDIR /usr/src
66
7+ RUN apt-get update && apt-get install inotify-tools -y && rm -rf /var/cache/apk/*
8+
79# Cache this step
810COPY Package.swift /usr/src
911RUN swift package update
@@ -17,4 +19,10 @@ ENV CONFIG=debug
1719# user can pass in LIVE=true
1820ENV LIVE=false
1921
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+
2028ENTRYPOINT ./entrypoint $CONFIG $LIVE
Original file line number Diff line number Diff line change 22
33CONFIG=$1
44LIVE=$2
5- KILL=false
6-
7- handle_interrupt () {
8- KILL=true
9- }
105
116build () {
127 swift build --configuration ${CONFIG}
@@ -27,18 +22,16 @@ build_and_run() {
2722}
2823
2924watch_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
3630 swift package update
3731 fi
3832 build_and_run
3933 echo " Waiting for changes to run application again."
4034 fi
41- sleep 2
4235 done
4336}
4437
@@ -47,7 +40,7 @@ entrypoint() {
4740}
4841
4942live_entrypoint () {
50- build_and_run
43+ run_application
5144 echo " Waiting for changes to run application again."
5245 watch_files &
5346 wait
Original file line number Diff line number Diff line change 6060 STS_BUILD_COMMAND=" docker build -t ${STS_NAME} ."
6161fi
6262
63- # live flag
63+ # live flag TODO: Fix conflict edge case with volume and live flags
6464if [ " $STS_LIVE_ENABLED " = true ] ; then
6565 STS_VOLUME_FLAG=" -v $PWD :/usr/src"
6666 STS_LIVE_FLAG=" -e LIVE=true"
@@ -80,6 +80,9 @@ case ${STS_COMMAND} in
8080 RUN_COMMAND=" docker run --rm -it ${STS_LIVE_FLAG} ${STS_VOLUME_FLAG} ${STS_NAME} "
8181 ;;
8282 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
8386 RUN_COMMAND=" docker run --rm ${STS_VOLUME_FLAG} --security-opt seccomp:unconfined -it \
8487 --entrypoint /usr/bin/swift \
8588 ${STS_NAME} \
@@ -91,9 +94,16 @@ case ${STS_COMMAND} in
9194 -lswiftTensorFlow"
9295 ;;
9396 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"
95102 ;;
96103 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
97107 RUN_COMMAND=" docker run --rm -v ${PWD} :/usr/src \
98108 --entrypoint /usr/bin/swift \
99109 ${STS_NAME} \
You can’t perform that action at this time.
0 commit comments