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
|
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
|
WORKDIR /go/src/github.com/Luzifer/tex-api
|
||||||
|
|
||||||
RUN set -ex \
|
RUN set -ex \
|
||||||
&& apk add --update git \
|
&& apk add --update git \
|
||||||
&& go install -ldflags "-X main.version=$(git describe --tags || git rev-parse --short HEAD || echo dev)"
|
&& 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>"
|
LABEL maintainer "Knut Ahlers <knut@ahlers.me>"
|
||||||
|
|
||||||
|
ENV SCRIPT=/usr/local/bin/tex-build.sh
|
||||||
|
|
||||||
RUN set -ex \
|
RUN set -ex \
|
||||||
&& apk --no-cache add \
|
&& apk --no-cache add \
|
||||||
bash \
|
bash \
|
||||||
|
@ -24,6 +26,6 @@ EXPOSE 3000
|
||||||
VOLUME ["/storage"]
|
VOLUME ["/storage"]
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/local/bin/tex-api"]
|
ENTRYPOINT ["/usr/local/bin/tex-api"]
|
||||||
CMD ["--script", "/usr/local/bin/tex-build.sh"]
|
CMD ["--"]
|
||||||
|
|
||||||
# vim: set ft=Dockerfile:
|
# vim: set ft=Dockerfile:
|
||||||
|
|
5
main.go
5
main.go
|
@ -22,7 +22,7 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
cfg = struct {
|
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)"`
|
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"`
|
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"`
|
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"`
|
VersionAndExit bool `flag:"version" default:"false" description:"Prints current version and exits"`
|
||||||
|
@ -96,6 +96,7 @@ func urlMust(u *url.URL, err error) *url.URL {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
rconfig.AutoEnv(true)
|
||||||
if err := rconfig.Parse(&cfg); err != nil {
|
if err := rconfig.Parse(&cfg); err != nil {
|
||||||
log.WithError(err).Fatal("Unable to parse commandline options")
|
log.WithError(err).Fatal("Unable to parse commandline options")
|
||||||
}
|
}
|
||||||
|
@ -276,7 +277,7 @@ func jobProcessor(uid uuid.UUID) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := exec.Command("/bin/bash", cfg.ExecutionScript) // #nosec G204
|
cmd := exec.Command("/bin/bash", cfg.Script) // #nosec G204
|
||||||
cmd.Dir = processingDir
|
cmd.Dir = processingDir
|
||||||
cmd.Stderr = log.StandardLogger().WriterLevel(log.ErrorLevel)
|
cmd.Stderr = log.StandardLogger().WriterLevel(log.ErrorLevel)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue