mirror of
https://github.com/Luzifer/tex-api.git
synced 2024-11-08 16:20:04 +00:00
Read parameters from ENV
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
de468be22a
commit
a6fd458d40
2 changed files with 11 additions and 8 deletions
|
@ -1,16 +1,18 @@
|
|||
FROM golang:alpine as builder
|
||||
|
||||
ADD . /go/src/github.com/Luzifer/tex-api
|
||||
COPY . /go/src/github.com/Luzifer/tex-api
|
||||
WORKDIR /go/src/github.com/Luzifer/tex-api
|
||||
|
||||
RUN set -ex \
|
||||
&& apk add --update git \
|
||||
&& go install -ldflags "-X main.version=$(git describe --tags || git rev-parse --short HEAD || echo dev)"
|
||||
|
||||
FROM alpine:latest
|
||||
FROM alpine:3.8
|
||||
|
||||
LABEL maintainer "Knut Ahlers <knut@ahlers.me>"
|
||||
|
||||
ENV SCRIPT=/usr/local/bin/tex-build.sh
|
||||
|
||||
RUN set -ex \
|
||||
&& apk --no-cache add \
|
||||
bash \
|
||||
|
@ -24,6 +26,6 @@ EXPOSE 3000
|
|||
VOLUME ["/storage"]
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/tex-api"]
|
||||
CMD ["--script", "/usr/local/bin/tex-build.sh"]
|
||||
CMD ["--"]
|
||||
|
||||
# vim: set ft=Dockerfile:
|
||||
|
|
11
main.go
11
main.go
|
@ -22,10 +22,10 @@ import (
|
|||
|
||||
var (
|
||||
cfg = struct {
|
||||
ExecutionScript string `flag:"script" default:"/go/src/github.com/Luzifer/tex-api/tex-build.sh" description:"Script to execute (needs to generate output directory)"`
|
||||
Listen string `flag:"listen" default:":3000" description:"IP/Port to listen on"`
|
||||
StorageDir string `flag:"storage-dir" default:"/storage" description:"Where to store uploaded ZIPs and resulting files"`
|
||||
VersionAndExit bool `flag:"version" default:"false" description:"Prints current version and exits"`
|
||||
Script string `flag:"script" default:"tex-build.sh" description:"Script to execute (needs to generate output directory)"`
|
||||
Listen string `flag:"listen" default:":3000" description:"IP/Port to listen on"`
|
||||
StorageDir string `flag:"storage-dir" default:"/storage" description:"Where to store uploaded ZIPs and resulting files"`
|
||||
VersionAndExit bool `flag:"version" default:"false" description:"Prints current version and exits"`
|
||||
}{}
|
||||
|
||||
version = "dev"
|
||||
|
@ -96,6 +96,7 @@ func urlMust(u *url.URL, err error) *url.URL {
|
|||
}
|
||||
|
||||
func init() {
|
||||
rconfig.AutoEnv(true)
|
||||
if err := rconfig.Parse(&cfg); err != nil {
|
||||
log.WithError(err).Fatal("Unable to parse commandline options")
|
||||
}
|
||||
|
@ -276,7 +277,7 @@ func jobProcessor(uid uuid.UUID) {
|
|||
return
|
||||
}
|
||||
|
||||
cmd := exec.Command("/bin/bash", cfg.ExecutionScript) // #nosec G204
|
||||
cmd := exec.Command("/bin/bash", cfg.Script) // #nosec G204
|
||||
cmd.Dir = processingDir
|
||||
cmd.Stderr = log.StandardLogger().WriterLevel(log.ErrorLevel)
|
||||
|
||||
|
|
Loading…
Reference in a new issue