Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Docker images for GemStone/64 #52

Merged
merged 25 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions .docker/gs64/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM launchpad-gs64:sut

CMD [ "launchpad", "start", "greeter" , "--name=DJ", "--title=Mr." ]
151 changes: 151 additions & 0 deletions .docker/gs64/docker-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
#!/usr/bin/env bash

readonly ANSI_BOLD="\\033[1m"
readonly ANSI_RED="\\033[31m"
readonly ANSI_GREEN="\\033[32m"
readonly ANSI_BLUE="\\033[34m"
readonly ANSI_RESET="\\033[0m"

function print_info() {
if [ -t 1 ]; then
printf "${ANSI_BOLD}${ANSI_BLUE}%s${ANSI_RESET}\\n" "$1"
else
echo "$1"
fi
}

function print_success() {
if [ -t 1 ]; then
printf "${ANSI_BOLD}${ANSI_GREEN}%s${ANSI_RESET}\\n" "$1"
else
echo "$1"
fi
}

function print_error() {
if [ -t 1 ]; then
printf "${ANSI_BOLD}${ANSI_RED}%s${ANSI_RESET}\\n" "$1" 1>&2
else
echo "$1" 1>&2
fi
}

function executeWithArguments() {
rm -rf logs out err
LAST_ARGUMENTS=$*
"$@" > out 2> err || true
}

function assertOutputIncludesMessage() {
local message=$1
local output=$2

if [ "$(grep -c "$message" "$output")" -eq 0 ]; then
print_error "Expected std$output to have: '$message' when invoked with $LAST_ARGUMENTS"
print_info "Output contents"
cat "$output"
exit 1
fi
}

set -e

print_info "Creating network"
docker network prune --force
docker network create --attachable launchpad-net

print_info "Starting stone"
docker run --rm --detach --name gs64-stone \
-e TZ="America/Argentina/Buenos_Aires" \
--cap-add=SYS_RESOURCE \
--network=launchpad-net \
--volume=$PWD:/opt/gemstone/projects/Launchpad:ro \

Check notice on line 62 in .docker/gs64/docker-tests.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] .docker/gs64/docker-tests.sh#L62 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./.docker/gs64/docker-tests.sh:62:11: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
--volume=$PWD/.docker/gs64/gem.conf:/opt/gemstone/conf/gem.conf \

Check notice on line 63 in .docker/gs64/docker-tests.sh

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] .docker/gs64/docker-tests.sh#L63 <ShellCheck.SC2086>

Double quote to prevent globbing and word splitting.
Raw output
./.docker/gs64/docker-tests.sh:63:18: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
gcotelli marked this conversation as resolved.
Show resolved Hide resolved
ghcr.io/ba-st/gs64-rowan:v3.7.0

sleep 1
print_info "Loading Launchpad in the stone"
docker exec -t -u gemstone gs64-stone ./load-rowan-project.sh Launchpad

print_info "Building base gem"
docker buildx build --tag launchpad-gs64:sut docker/gs64

print_info "Building examples gem"
gcotelli marked this conversation as resolved.
Show resolved Hide resolved
docker buildx build \
--tag launchpad-examples-gs64:sut \
--file .docker/gs64/Dockerfile \
.

print_info "Running basic test"
executeWithArguments docker run \
-e TZ="America/Argentina/Buenos_Aires" \
-e GS64_STONE_HOSTNAME="gs64-stone" \
--network=launchpad-net \
--cap-add=SYS_RESOURCE \
launchpad-examples-gs64:sut
assertOutputIncludesMessage '[INFO]' out
assertOutputIncludesMessage "Hi Mr. DJ!" out
print_success "OK"

# print_info "Running basic test with structured logging"
# executeWithArguments docker run -e LAUNCHPAD__LOG_FORMAT='json' launchpad-examples:sut
# assertOutputIncludesMessage '"level":"INFO"' out
# assertOutputIncludesMessage "Hi Mr. DJ!" out
# print_success "OK"

# print_info "Running --version test"
# executeWithArguments docker run launchpad-examples:sut launchpad --version
# assertOutputIncludesMessage "Launchpad" out
# print_success "OK"

# print_info "Running launchpad-list test"
# executeWithArguments docker run launchpad-examples:sut launchpad-list
# assertOutputIncludesMessage "broken greeter" out
# print_success "OK"

# print_info "Running launchpad-list --verbose test"
# executeWithArguments docker run launchpad-examples:sut launchpad-list --verbose
# assertOutputIncludesMessage "broken v0.0.1" out
# assertOutputIncludesMessage "greeter v1.0.0" out
# print_success "OK"

# print_info "Running launchpad-explain test"
# executeWithArguments docker run launchpad-examples:sut launchpad-explain broken
# assertOutputIncludesMessage "broken \[v0.0.1\] - A broken application" out
# executeWithArguments docker run launchpad-examples:sut launchpad-explain greeter
# assertOutputIncludesMessage "greeter \[v1.0.0\] - A greetings application" out
# executeWithArguments docker run launchpad-examples:sut launchpad-explain
# assertOutputIncludesMessage "\[ERROR\] Missing application name or option." err
# print_success "OK"

# print_info "Running launchpad-start greeter test"
# executeWithArguments docker run launchpad-examples:sut launchpad-start greeter --name=Juan
# assertOutputIncludesMessage "Hi Juan!" out
# print_success " Just name, OK"
# executeWithArguments docker run launchpad-examples:sut launchpad-start greeter --name=Julia --title=Miss
# assertOutputIncludesMessage "Hi Miss Julia!" out
# print_success " Name and title, OK"
# executeWithArguments docker run launchpad-examples:sut launchpad-start greeter --title=Miss
# assertOutputIncludesMessage "\[ERROR\] \"Name\" parameter not provided. You must provide one." err
# print_success " Missing name, OK"
# executeWithArguments docker run launchpad-examples:sut launchpad-start greeter
# assertOutputIncludesMessage "\[ERROR\] \"Name\" parameter not provided. You must provide one." err
# print_success "OK"

# print_info "Running launchpad-start broken test"
# executeWithArguments docker run launchpad-examples:sut launchpad-start broken --raise-error
# assertOutputIncludesMessage "\[INFO\] Obtaining configuration... \[DONE\]" out
# assertOutputIncludesMessage "\[ERROR\] Unexpected startup error: \"Doh!\"" err
# print_success "OK"

# print_info "Running launchpad-start command server test"
# # broken app keeps running when passed and invalid option
# executeWithArguments docker run --rm --name=broken-running -d launchpad-examples:sut launchpad-start broken -wait
# sleep 1
# rm -f out
# docker stop -t 30 broken-running > out
# assertOutputIncludesMessage "broken-running" out
# print_success "OK"

print_info "Stopping stone"
docker stop gs64-stone
2 changes: 2 additions & 0 deletions .docker/gs64/gem.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GEM_TEMPOBJ_CACHE_SIZE = 500000KB;

File renamed without changes.
4 changes: 2 additions & 2 deletions .docker/docker-tests.sh → .docker/pharo/docker-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ function assertOutputIncludesMessage() {
set -e

print_info "Building base image"
docker buildx build --tag launchpad:sut docker
docker buildx build --tag launchpad:sut docker/pharo

print_info "Building examples image"
docker buildx build \
--tag launchpad-examples:sut \
--file .docker/Dockerfile \
--file .docker/pharo/Dockerfile \
.

print_info "Running basic test"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ jobs:
uses: actions/checkout@v3
- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v4
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/launchpad
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
- name: Docker build and push
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: ./docker
context: ./docker/pharo
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
with:
fetch-depth: 2
- name: Run tests using Docker
run: ./.docker/docker-tests.sh
run: ./.docker/pharo/docker-tests.sh
7 changes: 7 additions & 0 deletions docker/gs64/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM ghcr.io/ba-st/gs64-gem:v3.7.0

COPY --chown=gemstone:users ./launchpad* ./
RUN set -eu; \
ln -s /opt/gemstone/launchpad /usr/local/bin/launchpad; \
chmod a+x /usr/local/bin/launchpad*; \
true
16 changes: 16 additions & 0 deletions docker/gs64/launchpad
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

readonly SYSTEM_USER_PASSWORD="${GS64_SYSTEM_USER_PASSWORD:-swordfish}"
readonly STONE_NAME="${GS64_STONE_SERVICE_NAME:-gs64stone}"

echo <<EOF >> .topazini
set gemstone !@${GS64_STONE_HOSTNAME}!${STONE_NAME} user SystemUser pass ${SYSTEM_USER_PASSWORD}
iferror exit 1
login
doit
CommandLineHandler activateWith: CommandLineArguments new
%
exit 0
EOF

exec topaz -l -- launchpad "$@"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading