Skip to content

Commit

Permalink
Merge pull request #41 from cyber-dojo/use-private-image-name
Browse files Browse the repository at this point in the history
Use private-image name for make-test
  • Loading branch information
JonJagger committed May 1, 2024
2 parents f7cabcd + 626dbfd commit bbf7b73
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 16 deletions.
7 changes: 5 additions & 2 deletions Makefile
@@ -1,10 +1,13 @@

SHORT_SHA := $(shell git rev-parse HEAD | head -c7)
IMAGE_NAME := cyberdojo/saver:${SHORT_SHA}
AWS_ACCOUNT_ID := 244531986313
AWS_REGION := eu-central-1
SERVICE_NAME := saver
IMAGE_NAME := ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/${SERVICE_NAME}:${SHORT_SHA}

.PHONY: image test snyk-container snyk-code

test:
test: image
${PWD}/sh/run_tests_with_coverage.sh

snyk-container: image
Expand Down
9 changes: 4 additions & 5 deletions app/config/healthcheck.sh
@@ -1,11 +1,10 @@
#!/bin/bash -Eeu
#!/usr/bin/env bash
set -Eeu

# Default Alpine image has wget (but not curl)

# Dockerfile has this
# HEALTHCHECK \
# --interval=1s --timeout=1s --retries=5 --start-period=5s \
# CMD ./config/heathcheck.sh
# HEALTHCHECK --interval=1s --timeout=1s --retries=5 --start-period=5s CMD /app/config/healthcheck.sh

# --interval=S time until 1st healthcheck
# --timeout=S fail if single healthcheck takes longer than this
Expand All @@ -15,7 +14,7 @@
readonly PORT="${CYBER_DOJO_SAVER_PORT}"
readonly READY_LOG_FILENAME=/tmp/ready.log

wget localhost:${PORT}/ready -q -O - > "${READY_LOG_FILENAME}" 2>&1
wget http://0.0.0.0:${PORT}/ready -q -O - >> "${READY_LOG_FILENAME}" 2>&1

# keep only most recent 500 lines
sed -i '501,$ d' "${READY_LOG_FILENAME}"
6 changes: 5 additions & 1 deletion app/source/model/id_pather.rb
Expand Up @@ -11,9 +11,13 @@ def kata_id_path(id, *parts)
def id_path3(type, id, *parts)
# Using 2/2/2 split.
# See https://github.com/cyber-dojo-tools/id-split-timer
args = ['', type, id[0..1], id[2..3], id[4..5]]
args = ['', type, id[0..1], id[2..3], id[4..5]] # [*]
args += parts.map(&:to_s)
File.join(*args)
end

end

# [*] This sometimes fails test_Ws5761()
# test/kata_exists.rb:24: in_kata do ... end
# NoMethodError: undefined method `[]' for nil
9 changes: 4 additions & 5 deletions client/config/healthcheck.sh
@@ -1,11 +1,10 @@
#!/bin/bash -Eeu
#!/usr/bin/env bash
set -Eeu

# Default Alpine image has wget (but not curl)

# Dockerfile has this
# HEALTHCHECK \
# --interval=1s --timeout=1s --retries=5 --start-period=5s \
# CMD ./config/heathcheck.sh
# HEALTHCHECK --interval=1s --timeout=1s --retries=5 --start-period=5s CMD ./config/healthcheck.sh

# --interval=S time until 1st healthcheck
# --timeout=S fail if single healthcheck takes longer than this
Expand All @@ -15,7 +14,7 @@
readonly PORT="${CYBER_DOJO_SAVER_CLIENT_PORT}"
readonly READY_LOG_FILENAME=/tmp/ready.log

wget localhost:${PORT}/ready -q -O - > "${READY_LOG_FILENAME}" 2>&1
wget http://0.0.0.0:${PORT}/ready -q -O - >> "${READY_LOG_FILENAME}" 2>&1

# keep only most recent 500 lines
sed -i '501,$ d' "${READY_LOG_FILENAME}"
4 changes: 1 addition & 3 deletions docker-compose.yml
@@ -1,6 +1,4 @@

version: '3.7'

volumes:
one_k:
external: true
Expand Down Expand Up @@ -28,7 +26,7 @@ services:
build:
args: [ COMMIT_SHA ]
context: .
image: cyberdojo/saver:${COMMIT_TAG}
image: ${CYBER_DOJO_SAVER_IMAGE}:${COMMIT_TAG}
user: saver
container_name: test_saver_server
env_file: [ .env ]
Expand Down
1 change: 1 addition & 0 deletions sh/build.sh
Expand Up @@ -18,6 +18,7 @@ popd
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
export $(echo_versioner_env_vars)
exit_non_zero_unless_installed docker docker-compose

images_build
images_check_sha_env_var
images_tag_latest
Expand Down
4 changes: 4 additions & 0 deletions sh/echo_versioner_env_vars.sh
Expand Up @@ -7,4 +7,8 @@ echo_versioner_env_vars()
docker run --rm cyberdojo/versioner:latest
echo CYBER_DOJO_SAVER_SHA="${sha}"
echo CYBER_DOJO_SAVER_TAG="${sha:0:7}"

local -r AWS_ACCOUNT_ID=244531986313
local -r AWS_REGION=eu-central-1
echo CYBER_DOJO_SAVER_IMAGE=${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/saver
}

0 comments on commit bbf7b73

Please sign in to comment.