Skip to content

Commit

Permalink
Move Dockerfile to repo root, make config/ and app/ top-level dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
JonJagger committed Dec 1, 2023
1 parent edb62cd commit 7e8f50f
Show file tree
Hide file tree
Showing 195 changed files with 33 additions and 89 deletions.
2 changes: 1 addition & 1 deletion sources/server/.dockerignore → .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
*
!code/
!app/
!config/
68 changes: 0 additions & 68 deletions .github/workflows/dead.main.yml

This file was deleted.

6 changes: 3 additions & 3 deletions sources/server/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ARG BASE_IMAGE=cyberdojo/sinatra-base:ad4c29a
FROM ${BASE_IMAGE}
LABEL maintainer=jon@jaggersoft.com

WORKDIR /app
WORKDIR /dashboard
COPY --chown=nobody:nogroup . .

ARG COMMIT_SHA
Expand All @@ -14,6 +14,6 @@ ARG BASE_IMAGE
ENV BASE_IMAGE=${BASE_IMAGE}

USER nobody
HEALTHCHECK --interval=1s --timeout=1s --retries=5 --start-period=5s CMD /app/config/healthcheck.sh
HEALTHCHECK --interval=1s --timeout=1s --retries=5 --start-period=5s CMD /dashboard/config/healthcheck.sh
ENTRYPOINT ["/sbin/tini", "-g", "--"]
CMD [ "/app/config/up.sh" ]
CMD [ "/dashboard/config/up.sh" ]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion build_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -Eeu
export MY_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
export SCRIPTS_DIR="${MY_DIR}/sh"

source "${SCRIPTS_DIR}/lib.sh"
source "${SCRIPTS_DIR}/build_images.sh"
source "${SCRIPTS_DIR}/config.sh"
source "${SCRIPTS_DIR}/containers_down.sh"
Expand All @@ -14,7 +15,6 @@ source "${SCRIPTS_DIR}/echo_seconds.sh"
source "${SCRIPTS_DIR}/exit_non_zero_unless_installed.sh"
source "${SCRIPTS_DIR}/exit_zero_if_build_only.sh"
source "${SCRIPTS_DIR}/exit_zero_if_show_help.sh"
source "${SCRIPTS_DIR}/lib.sh"
source "${SCRIPTS_DIR}/on_ci_publish_images.sh"
source "${SCRIPTS_DIR}/test_in_containers.sh"
source "${SCRIPTS_DIR}/echo_versioner_env_vars.sh"
Expand Down
4 changes: 2 additions & 2 deletions sources/server/config/config.ru → config/config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if ENV['CYBER_DOJO_PROMETHEUS'] === 'true'
use Prometheus::Middleware::Exporter
end

require_relative '../code/app'
require_relative '../code/externals'
require_relative '../app/app'
require_relative '../app/externals'
externals = Externals.new
run App.new(externals)
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
# 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/heathcheck.sh

# --interval=S time until 1st healthcheck
# --timeout=S fail if single healthcheck takes longer than this
# --retries=N number of tries until container considered unhealthy
# --start-period=S grace period when healthcheck fails dont count towards --retries
# --start-period=S grace period when healthcheck fails don't count towards --retries

#readonly PORT="${CYBER_DOJO_K8S_PORT:-${CYBER_DOJO_DASHBOARD_PORT}}"
readonly PORT="${CYBER_DOJO_DASHBOARD_PORT}"
readonly READY_LOG_FILENAME=/tmp/ready.log

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions sources/server/config/up.sh → config/up.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -Eeu
#!/usr/bin/env bash
set -Eeu

#readonly PORT="${CYBER_DOJO_K8S_PORT:-${CYBER_DOJO_DASHBOARD_PORT}}"
readonly PORT="${CYBER_DOJO_DASHBOARD_PORT}"
readonly MY_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ services:
image: cyberdojo/dashboard:${COMMIT_TAG}
user: nobody
build:
context: .
args: [ COMMIT_SHA ]
context: sources/server
container_name: test_dashboard_server
depends_on:
- differ
Expand All @@ -52,5 +52,5 @@ services:
restart: "no"
tmpfs: /tmp
volumes:
- ./sources/server:/app:ro
- ./app:/app:ro
- ./test:/test:ro
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion sh/containers_up_healthy_and_clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ top_5()
# - - - - - - - - - - - - - - - - - - -
clean_top_5()
{
# 1st 6 lines on Puma
# 1st 5 lines on Puma
local -r L1="Puma starting in single mode..."
local -r L2='* Puma version: 6.4.0 (ruby 3.2.2-p53) ("The Eagle of Durango")'
local -r L3="* Min threads: 0"
Expand Down
4 changes: 2 additions & 2 deletions sh/create_docker_compose_yml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ services:
image: $(server_image):\${COMMIT_TAG}
user: $(server_user)
build:
context: .
args: [ COMMIT_SHA ]
context: $(sources_dir)/$(server_name)
container_name: $(server_container)
depends_on:
- differ
Expand All @@ -67,7 +67,7 @@ services:
restart: "no"
tmpfs: /tmp
volumes:
- ./$(sources_dir)/$(server_name):/app:ro
- ./app:/app:ro
- ./$(tests_dir):/test:ro
EOF
}
2 changes: 1 addition & 1 deletion sh/run_tests_with_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set -Eeu

export SCRIPTS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

source "${SCRIPTS_DIR}/lib.sh"
source "${SCRIPTS_DIR}/build_images.sh"
source "${SCRIPTS_DIR}/config.sh"
source "${SCRIPTS_DIR}/containers_down.sh"
Expand All @@ -13,7 +14,6 @@ source "${SCRIPTS_DIR}/echo_seconds.sh"
source "${SCRIPTS_DIR}/exit_non_zero_unless_installed.sh"
source "${SCRIPTS_DIR}/exit_zero_if_build_only.sh"
source "${SCRIPTS_DIR}/exit_zero_if_show_help.sh"
source "${SCRIPTS_DIR}/lib.sh"
source "${SCRIPTS_DIR}/test_in_containers.sh"
source "${SCRIPTS_DIR}/echo_versioner_env_vars.sh"
export $(echo_versioner_env_vars)
Expand Down
14 changes: 14 additions & 0 deletions sh/wait_for_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -Eu

TAG="$(echo ${GITHUB_SHA} | head -c7)"
MAX_ATTEMPTS=30 # every 10s for 5 minutes
ATTEMPTS=1

until docker pull cyberdojo/dashboard:${TAG}
do
sleep 10
[[ ${ATTEMPTS} -eq ${MAX_ATTEMPTS} ]] && echo "Failed!" && exit 1
((ATTEMPTS++))
echo "Trying docker pull cyberdojo/dashboard:${TAG} again. Attempt #${ATTEMPTS}"
done
2 changes: 1 addition & 1 deletion test/id58_test_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'rack/test'

def require_source(required)
require_relative "../app/code/#{required}"
require_relative "../dashboard/app/#{required}"
end

class Id58TestBase < Minitest::Test
Expand Down

0 comments on commit 7e8f50f

Please sign in to comment.