From 92ee590d9489f2fd89ec977e3b8a94d63d95f21c Mon Sep 17 00:00:00 2001 From: Dominic Grimm Date: Mon, 10 Jan 2022 17:53:38 +0100 Subject: [PATCH 1/3] Simplified dockerfile --- docker/backend/Dockerfile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docker/backend/Dockerfile b/docker/backend/Dockerfile index eed1ef4..1796a4a 100644 --- a/docker/backend/Dockerfile +++ b/docker/backend/Dockerfile @@ -9,8 +9,7 @@ WORKDIR /app COPY --from=micrate-deps /app/shard.yml /app/shard.lock ./ COPY --from=micrate-deps /app/lib lib/ COPY ./micrate/src ./src -COPY ./scripts ./scripts -RUN . ./scripts/build.sh ${BUILD_ENV} +RUN shards build --production --static --release --no-debug --verbose -s -p -t FROM crystallang/crystal:latest-alpine as deps WORKDIR /app @@ -24,9 +23,11 @@ WORKDIR /app COPY --from=deps /app/shard.yml /app/shard.lock ./ COPY --from=deps /app/lib ./lib COPY ./src ./src -COPY ./scripts ./scripts -RUN . ./scripts/build.sh ${BUILD_ENV} - +RUN if [ "${BUILD_ENV}" = "development" ]; then \ + shards build --static --verbose -s -p -t; \ + else \ + shards build --static --release --no-debug --verbose -s -p -t; \ + fi FROM scratch as runner WORKDIR / COPY --from=micrate-builder /app/bin/micrate ./bin/micrate From b5cfcf05554b9b6bd680864ac35a4b69d08cccff Mon Sep 17 00:00:00 2001 From: Dominic Grimm Date: Mon, 10 Jan 2022 17:53:51 +0100 Subject: [PATCH 2/3] Removed build script --- docker/backend/scripts/build.sh | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 docker/backend/scripts/build.sh diff --git a/docker/backend/scripts/build.sh b/docker/backend/scripts/build.sh deleted file mode 100644 index 7cc2140..0000000 --- a/docker/backend/scripts/build.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env sh - -BASE_FLAGS="--production --static --verbose -s -p -t" -DEV_FLAGS="$BASE_FLAGS" -PROD_FLAGS="--release --no-debug $BASE_FLAGS" - -echo "Building targets in '$1' mode..." -if [ "$1" = "development" ]; then - # shellcheck disable=SC2086 - time shards build $DEV_FLAGS -else - # shellcheck disable=SC2086 - time shards build $PROD_FLAGS -fi From e2b909a191d7fcee81a3777619d6ed5e5c7f8342 Mon Sep 17 00:00:00 2001 From: Dominic Grimm Date: Mon, 10 Jan 2022 17:54:00 +0100 Subject: [PATCH 3/3] Added fancyline usage --- docker/backend/shard.lock | 12 ++++++++++++ docker/backend/shard.yml | 2 ++ docker/backend/src/mw/cli.cr | 18 +++++++++++++++--- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/docker/backend/shard.lock b/docker/backend/shard.lock index c051c28..314bba3 100644 --- a/docker/backend/shard.lock +++ b/docker/backend/shard.lock @@ -20,10 +20,22 @@ shards: git: https://github.com/axentro/crystal-argon2.git version: 0.1.3 + cute: + git: https://github.com/papierkorb/cute.git + version: 0.4.0 + db: git: https://github.com/crystal-lang/crystal-db.git version: 0.10.1 + fancyline: + git: https://github.com/papierkorb/fancyline.git + version: 0.4.1 + + future: + git: https://github.com/crystal-community/future.cr.git + version: 1.0.0 + granite: git: https://github.com/amberframework/granite.git version: 0.23.0 diff --git a/docker/backend/shard.yml b/docker/backend/shard.yml index 12498d0..f4f656e 100644 --- a/docker/backend/shard.yml +++ b/docker/backend/shard.yml @@ -34,3 +34,5 @@ dependencies: github: mrrooijen/commander compiled_license: github: grimmigerFuchs/compiled_license + fancyline: + github: Papierkorb/fancyline diff --git a/docker/backend/src/mw/cli.cr b/docker/backend/src/mw/cli.cr index 266c040..891ab2b 100644 --- a/docker/backend/src/mw/cli.cr +++ b/docker/backend/src/mw/cli.cr @@ -1,15 +1,27 @@ require "commander" require "compiled_license" +require "fancyline" require "./db" module MW - module Cli + module CLI extend self + private FANCY = Fancyline.new + + FANCY.actions.set Fancyline::Key::Control::CtrlC do + exit + end + private def input(prompt : String) : String - print prompt - (gets || "").chomp.strip + x = FANCY.readline(prompt) + + if x + x.chomp.strip + else + "" + end end cli = Commander::Command.new do |cmd|