diff --git a/clients/README.md b/clients/README.md index b3b20ef..b14af44 100644 --- a/clients/README.md +++ b/clients/README.md @@ -151,10 +151,10 @@ arguments and have similar output. ./go-demo size 2024/04/10 13:07:23 session: 68632e4d-70c4-43f4-8532-95ab5f583177 connected to address localhost:1408 - Trade cache size = 200005 - Price cache size = 6 + 2024/04/10 13:07:24 Trade cache size = 200005 + 2024/04/10 13:07:24 Price cache size = 6 - 2024/04/10 13:07:23 closed session 68632e4d-70c4-43f4-8532-95ab5f583177 + 2024/04/10 13:07:25 closed session 68632e4d-70c4-43f4-8532-95ab5f583177 ``` 3. Add trades for a symbol by running `./go-demo add-trades ORCL 100000` @@ -163,8 +163,8 @@ arguments and have similar output. ./go-demo add-trades ORCL 100000 2024/04/10 13:12:11 session: c070b210-3494-4bf2-962e-24b526c17d56 connected to address localhost:1408 - Adding 100000 random trades for ORCL... - Trades cache size is now 300005 + 2024/04/10 13:12:11 Adding 100000 random trades for ORCL... + 2024/04/10 13:12:11 Trades cache size is now 300005 2024/04/10 13:12:14 closed session c070b210-3494-4bf2-962e-24b526c17d56 ``` diff --git a/clients/build-docker-images.sh b/clients/build-docker-images.sh new file mode 100755 index 0000000..c1245b4 --- /dev/null +++ b/clients/build-docker-images.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# +# Copyright (c) 2024 Oracle and/or its affiliates. +# +# You may not use this file except in compliance with the Universal Permissive +# License (UPL), Version 1.0 (the "License.") +# +# You may obtain a copy of the License at https: //opensource.org/licenses/UPL. +# +# Unless required by applicable law or agreed to in writing, software distributed +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, either express or implied. +# +# See the License for the specific language governing permissions and limitations +# under the License. +# +# + +RELEASE_IMAGE_PREFIX=ghcr.io/coherence-community + +echo "Building Go image..." +cd go +CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./go-demo . +docker build -t ${RELEASE_IMAGE_PREFIX}/go-demo . +cd .. + +echo "Building JavaScript image..." +cd js +docker build -t ${RELEASE_IMAGE_PREFIX}/js-demo . +cd .. + +echo "Building Python image..." +cd py +docker build -t ${RELEASE_IMAGE_PREFIX}/py-demo . +cd .. + + + + diff --git a/clients/go/Dockerfile b/clients/go/Dockerfile new file mode 100644 index 0000000..a88415e --- /dev/null +++ b/clients/go/Dockerfile @@ -0,0 +1,5 @@ +FROM scratch + +COPY go-demo /files/go-demo +ENTRYPOINT ["/files/go-demo"] +CMD [] diff --git a/clients/go/main.go b/clients/go/main.go index ac818d6..bf529c1 100644 --- a/clients/go/main.go +++ b/clients/go/main.go @@ -186,7 +186,7 @@ func addTrades(trades coherence.NamedCache[string, Trade], prices coherence.Name // add using efficient PuAll buffer := make(map[string]Trade, 0) - fmt.Printf("Adding %d random trades for %s...\n", count, symbol) + log.Printf("Adding %d random trades for %s...\n", count, symbol) for i := 0; i < count; i++ { trade := newTrade(symbol, rand.Intn(1000)+1, currentPrice.Price) @@ -210,7 +210,7 @@ func addTrades(trades coherence.NamedCache[string, Trade], prices coherence.Name size, err := trades.Size(ctx) if err == nil { - fmt.Printf("Trades cache size is now %d\n", size) + log.Printf("Trades cache size is now %d\n", size) fmt.Println() } diff --git a/clients/js/Dockerfile b/clients/js/Dockerfile new file mode 100644 index 0000000..6a23708 --- /dev/null +++ b/clients/js/Dockerfile @@ -0,0 +1,11 @@ +FROM node:18-alpine +# Create app directory +WORKDIR /usr/src/app +# Install app dependencies +# A wildcard is used to ensure both package.json AND package-lock.json are copied +COPY package*.json ./ +COPY main.js ./ + +RUN npm install + +CMD [ "node", "main.js" ] \ No newline at end of file diff --git a/clients/py/Dockerfile b/clients/py/Dockerfile new file mode 100644 index 0000000..1792262 --- /dev/null +++ b/clients/py/Dockerfile @@ -0,0 +1,4 @@ +FROM python:3.11 +ADD main.py . +RUN pip install coherence-client==1.0.2 +CMD ["python3", "./main.py"]