diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5cb0dea --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +VERSION=`git describe --always` + +build: build-api build-web + +build-api: + -mkdir dist + make -C api personal_measure_api + tar czf dist/personal-measure-api-${VERSION}.tar.gz -C api personal_measure_api + +build-web: + -mkdir dist + (cd web && npm run build) + tar czf dist/personal-measure-web-${VERSION}.tar.gz -C web/dist . + +#deploy-api: build-api diff --git a/api/Dockerfile b/api/Dockerfile new file mode 100644 index 0000000..502a90c --- /dev/null +++ b/api/Dockerfile @@ -0,0 +1,21 @@ +FROM 32707f62ca3b AS build +MAINTAINER jonathan@jdbernard.com + +#RUN apt-get install -y libssl-dev +COPY personal_measure_api.nimble /pm-api/ +COPY src /pm-api/src +WORKDIR /pm-api +RUN nimble build -y + +FROM alpine +#RUN apt-get install -y postgresql-client +RUN apk -v --update add --no-cache \ + ca-certificates \ + libressl2.7-libssl \ + libressl2.7-libcrypto \ + pcre \ + postgresql-client + +COPY --from=build /pm-api/personal_measure_api / +COPY personal_measure_api.config.prod.json /personal_measure_api.config.json +CMD ["/personal_measure_api", "serve"] diff --git a/api/personal_measure_api.config.prod.json b/api/personal_measure_api.config.prod.json new file mode 100644 index 0000000..758520c --- /dev/null +++ b/api/personal_measure_api.config.prod.json @@ -0,0 +1,5 @@ +{ + "debug":false, + "port":80, + "pwdCost":11 +} diff --git a/api/personal_measure_api.nimble b/api/personal_measure_api.nimble index ac9a149..b861016 100644 --- a/api/personal_measure_api.nimble +++ b/api/personal_measure_api.nimble @@ -13,6 +13,8 @@ skipExt = @["nim"] # Dependencies -requires @["nim >= 0.19.4", "bcrypt", "cliutils >= 0.6.3", "docopt >= 0.6.8", - "isaac >= 0.1.3", "jester >= 0.4.1", "jwt", "tempfile", "timeutils >= 0.4.0", - "uuids >= 0.1.10" ] +requires @["nim >= 0.19.4", "bcrypt", "docopt >= 0.6.8", "isaac >= 0.1.3", + "jester >= 0.4.1", "jwt", "tempfile", "uuids >= 0.1.10" ] + +requires "https://git.jdb-labs.com/jdb/nim-cli-utils.git >= 0.6.3" +requires "https://git.jdb-labs.com/jdb/nim-time-utils.git >= 0.4.0" diff --git a/api/src/main/nim/personal_measure_api.nim b/api/src/main/nim/personal_measure_api.nim index 09b3b12..94f4497 100644 --- a/api/src/main/nim/personal_measure_api.nim +++ b/api/src/main/nim/personal_measure_api.nim @@ -37,11 +37,11 @@ proc loadConfig*(args: Table[string, docopt.Value] = initTable[string, docopt.Va let cfg = CombinedConfig(docopt: args, json: json) result = PMApiConfig( - authSecret: cfg.getVal("authSecret"), - dbConnString: cfg.getVal("dbConnString"), + authSecret: cfg.getVal("auth-secret"), + dbConnString: cfg.getVal("db-conn-string"), debug: "true".startsWith(cfg.getVal("debug", "false").toLower()), port: parseInt(cfg.getVal("port", "8080")), - pwdCost: cast[int8](parseInt(cfg.getVal("pwdCost", "11")))) + pwdCost: cast[int8](parseInt(cfg.getVal("pwd-cost", "11")))) proc initContext(args: Table[string, docopt.Value]): PMApiContext = @@ -68,7 +68,7 @@ Usage: Options: - -C, --config Location of the config file (defaults to personal_measure.config.json) + -C, --config Location of the config file (defaults to personal_measure_api.config.json) --salt Use a given salt for password hashing --pwdCost Specify the cost for password hashing """