Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add script for building polyglot docker images #87

Merged
merged 3 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions clients/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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
```
Expand Down
39 changes: 39 additions & 0 deletions clients/build-docker-images.sh
Original file line number Diff line number Diff line change
@@ -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 ..




5 changes: 5 additions & 0 deletions clients/go/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM scratch

COPY go-demo /files/go-demo
ENTRYPOINT ["/files/go-demo"]
CMD []
4 changes: 2 additions & 2 deletions clients/go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
}

Expand Down
11 changes: 11 additions & 0 deletions clients/js/Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
4 changes: 4 additions & 0 deletions clients/py/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM python:3.11
ADD main.py .
RUN pip install coherence-client==1.0.2
CMD ["python3", "./main.py"]
Loading