Skip to content

Commit

Permalink
Namespace program versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ggeoffrey committed Mar 13, 2023
1 parent cee3b15 commit 4d64321
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ COPY src-docs src-docs
COPY src-build src-build
COPY resources resources
ARG REBUILD=unknown
ARG VERSION
RUN clojure -X:build uberjar :jar-name "app.jar" :verbose true :version $VERSION
ARG HYPERFIDDLE_ELECTRIC_VERSION
RUN clojure -X:build uberjar :jar-name "app.jar" :verbose true :version $HYPERFIDDLE_ELECTRIC_VERSION

FROM amazoncorretto:11 AS app
WORKDIR /app
COPY --from=build /app/app.jar app.jar
# not required - included for Directory Explorer demo
COPY --from=node-deps /app/node_modules node_modules
EXPOSE 8080
ARG VERSION
ENV VERSION=$VERSION
CMD java -DHYPERFIDDLE_ELECTRIC_VERSION=$VERSION -jar app.jar
ARG HYPERFIDDLE_ELECTRIC_VERSION
ENV HYPERFIDDLE_ELECTRIC_VERSION=$HYPERFIDDLE_ELECTRIC_VERSION
CMD java -DHYPERFIDDLE_ELECTRIC_VERSION=$HYPERFIDDLE_ELECTRIC_VERSION -jar app.jar
4 changes: 2 additions & 2 deletions src-build/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ deploy rights to the target coordinates.
```shell
clojure -X:build build-client # optimized release build
clojure -X:build uberjar # contains demos and demo server, currently
docker build --build-arg VERSION=$(git describe --tags --long) -t electric .
NO_COLOR=1 flyctl deploy --build-arg VERSION=$(git describe --tags --long)
docker build --build-arg HYPERFIDDLE_ELECTRIC_VERSION=$(git describe --tags --long) -t electric .
NO_COLOR=1 flyctl deploy --build-arg HYPERFIDDLE_ELECTRIC_VERSION=$(git describe --tags --long)
```

- `NO_COLOR=1` disables docker-cli fancy shell GUI, so that we see the full log (not paginated) in case of exception
Expand Down
4 changes: 2 additions & 2 deletions src/hyperfiddle/electric_client.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[hyperfiddle.electric.impl.io :as io])
(:import missionary.Cancelled))

(goog-define VERSION "dev")
(goog-define VERSION "")

(do-browser
(defn server-url []
Expand All @@ -16,7 +16,7 @@
"http:" "ws:"
"https:" "wss:"
(throw (ex-info "Unexpected protocol" proto))))
(.. url -searchParams (set "version" VERSION))
(.. url -searchParams (set "HYPERFIDDLE_ELECTRIC_CLIENT_VERSION" VERSION))
(.toString url))))

(def ^:dynamic *ws-server-url* (do-browser (server-url)))
Expand Down
4 changes: 2 additions & 2 deletions src/hyperfiddle/electric_jetty_server.clj
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@
(.setMinGzipSize 1024)
(.setHandler (.getHandler server)))))

(def ^:const VERSION (not-empty (System/getProperty "HYPERFIDDLE_ELECTRIC_VERSION")))
(def ^:const VERSION (not-empty (System/getProperty "HYPERFIDDLE_ELECTRIC_SERVER_VERSION")))

(defn wrap-reject-stale-client [next-handler]
(fn [ring-req]
(let [client-version (get-in ring-req [:query-params "version"])]
(let [client-version (get-in ring-req [:query-params "HYPERFIDDLE_ELECTRIC_CLIENT_VERSION"])]
(cond
(nil? VERSION) (next-handler ring-req)
(= client-version VERSION) (next-handler ring-req)
Expand Down

0 comments on commit 4d64321

Please sign in to comment.