WIP Dockerizing API.
This commit is contained in:
parent
fcf0cf18f6
commit
3e68462c28
15
Makefile
Normal file
15
Makefile
Normal file
@ -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
|
21
api/Dockerfile
Normal file
21
api/Dockerfile
Normal file
@ -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"]
|
5
api/personal_measure_api.config.prod.json
Normal file
5
api/personal_measure_api.config.prod.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"debug":false,
|
||||||
|
"port":80,
|
||||||
|
"pwdCost":11
|
||||||
|
}
|
@ -13,6 +13,8 @@ skipExt = @["nim"]
|
|||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
|
||||||
requires @["nim >= 0.19.4", "bcrypt", "cliutils >= 0.6.3", "docopt >= 0.6.8",
|
requires @["nim >= 0.19.4", "bcrypt", "docopt >= 0.6.8", "isaac >= 0.1.3",
|
||||||
"isaac >= 0.1.3", "jester >= 0.4.1", "jwt", "tempfile", "timeutils >= 0.4.0",
|
"jester >= 0.4.1", "jwt", "tempfile", "uuids >= 0.1.10" ]
|
||||||
"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"
|
||||||
|
@ -37,11 +37,11 @@ proc loadConfig*(args: Table[string, docopt.Value] = initTable[string, docopt.Va
|
|||||||
let cfg = CombinedConfig(docopt: args, json: json)
|
let cfg = CombinedConfig(docopt: args, json: json)
|
||||||
|
|
||||||
result = PMApiConfig(
|
result = PMApiConfig(
|
||||||
authSecret: cfg.getVal("authSecret"),
|
authSecret: cfg.getVal("auth-secret"),
|
||||||
dbConnString: cfg.getVal("dbConnString"),
|
dbConnString: cfg.getVal("db-conn-string"),
|
||||||
debug: "true".startsWith(cfg.getVal("debug", "false").toLower()),
|
debug: "true".startsWith(cfg.getVal("debug", "false").toLower()),
|
||||||
port: parseInt(cfg.getVal("port", "8080")),
|
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 =
|
proc initContext(args: Table[string, docopt.Value]): PMApiContext =
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ Usage:
|
|||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
|
||||||
-C, --config <cfgFile> Location of the config file (defaults to personal_measure.config.json)
|
-C, --config <cfgFile> Location of the config file (defaults to personal_measure_api.config.json)
|
||||||
--salt <salt> Use a given salt for password hashing
|
--salt <salt> Use a given salt for password hashing
|
||||||
--pwdCost <cost> Specify the cost for password hashing
|
--pwdCost <cost> Specify the cost for password hashing
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user