Add web server

This commit is contained in:
Anton Vakhrushev 2019-11-05 21:37:09 +03:00
parent 73ed1eca06
commit 72fe4e5569
6 changed files with 52 additions and 2 deletions

View File

@ -1,10 +1,12 @@
FROM alpine:edge as builder
FROM alpine:3.10.3 as builder
# Install crystal and dev libs
RUN apk add -u \
make \
crystal \
shards \
make \
tzdata \
libc-dev \
zlib-dev \
libressl-dev \
yaml-dev

View File

@ -23,6 +23,10 @@ format:
run: format
crystal run $(ENTRY_POINT)
.PHONY: run-server
run-server: format
server run $(ENTRY_POINT)
.PHONY: spec
spec: format
crystal spec --warnings all --error-on-warnings --error-trace

View File

@ -4,3 +4,19 @@ shards:
github: crystal-ameba/ameba
version: 0.10.1
exception_page:
github: crystal-loot/exception_page
version: 0.1.2
kemal:
github: kemalcr/kemal
version: 0.25.2
kilt:
github: jeromegn/kilt
version: 0.4.0
radix:
github: luislavena/radix
version: 0.3.9

View File

@ -12,6 +12,11 @@ crystal: 0.31.1
license: MIT
dependencies:
kemal:
github: kemalcr/kemal
version: ~> 0.25.2
development_dependencies:
ameba:
github: crystal-ameba/ameba

View File

@ -1,3 +1,4 @@
require "kemal"
require "./dayoff/**"
module Dayoff
@ -9,3 +10,9 @@ module Dayoff
end
end
end
get "/" do
"Hello World!"
end
Kemal.run

16
tools/server Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -eu
TTY=
if [ -t 1 ] ; then
TTY=-t
fi
docker run -i $TTY \
-u "$(id -u):$(id -g)" \
-v "$PWD:/app" \
-p "3000:3000" \
-w "/app" \
dayoff-crystal crystal "$@"