fix(docker): fix Dockerfile
This commit is contained in:
@@ -1,11 +1,16 @@
|
|||||||
|
# Build stage
|
||||||
FROM golang:latest AS builder
|
FROM golang:latest AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN go build -v -o svg-templater ./...
|
RUN CGO_ENABLED=0 GOOS=linux go build -v -o svg-templater ./cmd/svg-templater
|
||||||
|
|
||||||
|
# Final stage
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
WORKDIR /root/
|
WORKDIR /root/
|
||||||
|
EXPOSE 3000
|
||||||
|
VOLUME ["/var/lib/svg-templater"]
|
||||||
|
RUN apk add inkscape fontconfig
|
||||||
COPY --from=builder /app/svg-templater /usr/local/bin/svg-templater
|
COPY --from=builder /app/svg-templater /usr/local/bin/svg-templater
|
||||||
CMD ["svg-templater"]
|
CMD ["svg-templater"]
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -7,7 +7,7 @@ require github.com/glebarez/go-sqlite v1.22.0
|
|||||||
require (
|
require (
|
||||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
github.com/google/uuid v1.5.0 // indirect
|
github.com/google/uuid v1.5.0 // indirect
|
||||||
github.com/hymkor/exregexp-go v0.2.0 // indirect
|
github.com/hymkor/exregexp-go v0.2.0
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||||
golang.org/x/sys v0.15.0 // indirect
|
golang.org/x/sys v0.15.0 // indirect
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -74,11 +75,11 @@ func runCommand(input string, param ConversionParameters) (io.ReadCloser, error)
|
|||||||
args = append(args, "-o", outFile)
|
args = append(args, "-o", outFile)
|
||||||
args = append(args, input)
|
args = append(args, input)
|
||||||
|
|
||||||
cmd := exec.Command("/opt/homebrew/bin/inkscape", args...)
|
cmd := exec.Command("inkscape", args...)
|
||||||
cmd.Dir = svg.TempDir
|
cmd.Dir = svg.TempDir
|
||||||
|
|
||||||
out, err := cmd.CombinedOutput()
|
out, err := cmd.CombinedOutput()
|
||||||
|
log.Println(string(out))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("inkscape failed: %w: %s", err, string(out))
|
return nil, fmt.Errorf("inkscape failed: %w: %s", err, string(out))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user