mirror of
https://github.com/alexandrev/xslt-lab.git
synced 2026-09-13 08:43:16 +00:00
Include Saxon dependencies in runtime
This commit is contained in:
@@ -49,6 +49,8 @@ docker build -t xslt-playground-backend backend
|
||||
```
|
||||
|
||||
By default it listens on port `8000` as configured in `backend/app.config`.
|
||||
The same file sets `saxon_classpath` so the Java process can load Saxon and
|
||||
its dependencies from `/opt/saxon/*`.
|
||||
|
||||
### Environment
|
||||
|
||||
@@ -58,6 +60,7 @@ authentication. Provide these via environment variables:
|
||||
```bash
|
||||
export DATABASE_URL="postgres://user:pass@localhost/dbname"
|
||||
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/serviceAccount.json
|
||||
export SAXON_CLASSPATH=/opt/saxon/*
|
||||
```
|
||||
|
||||
The Firebase project ID is read from the credentials file.
|
||||
|
||||
+6
-7
@@ -7,13 +7,11 @@ RUN apk add --no-cache git
|
||||
# Establecer directorio de trabajo
|
||||
WORKDIR /app/src
|
||||
|
||||
# Copiar los archivos
|
||||
COPY src/ .
|
||||
# Copiar los archivos del backend
|
||||
COPY src/ ./
|
||||
|
||||
# Compilar el binario estático
|
||||
RUN go mod init xslt-playground && \
|
||||
go get github.com/gin-gonic/gin && \
|
||||
go build -o server .
|
||||
# Descargar dependencias y compilar
|
||||
RUN go mod tidy && go build -o server .
|
||||
|
||||
# Etapa final (runtime)
|
||||
FROM alpine:latest
|
||||
@@ -30,7 +28,8 @@ COPY src/app.config .
|
||||
|
||||
# Crear carpeta para Saxon y descargarlo
|
||||
RUN mkdir -p /opt/saxon && \
|
||||
curl -L -o /opt/saxon/saxon-he.jar https://repo1.maven.org/maven2/net/sf/saxon/Saxon-HE/11.6/Saxon-HE-11.6.jar
|
||||
curl -L -o /opt/saxon/saxon-he.jar https://repo1.maven.org/maven2/net/sf/saxon/Saxon-HE/11.6/Saxon-HE-11.6.jar && \
|
||||
curl -L -o /opt/saxon/xmlresolver.jar https://repo1.maven.org/maven2/org/xmlresolver/xmlresolver/4.5.0/xmlresolver-4.5.0.jar
|
||||
|
||||
# Exponer el puerto por defecto y ejecutar el binario
|
||||
EXPOSE 8000
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"port": "8000",
|
||||
"saxon_path": "/opt/saxon/saxon-he.jar"
|
||||
"saxon_classpath": "/opt/saxon/*"
|
||||
}
|
||||
|
||||
+5
-2
@@ -35,7 +35,7 @@ type TransformResponse struct {
|
||||
|
||||
type AppConfig struct {
|
||||
Port string `json:"port"`
|
||||
SaxonPath string `json:"saxon_path"`
|
||||
SaxonClasspath string `json:"saxon_classpath"`
|
||||
DatabaseURL string `json:"database_url"`
|
||||
FirebaseCredentials string `json:"firebase_credentials"`
|
||||
}
|
||||
@@ -64,6 +64,9 @@ func loadConfig(filename string) (*AppConfig, error) {
|
||||
if v := os.Getenv("GOOGLE_APPLICATION_CREDENTIALS"); v != "" {
|
||||
config.FirebaseCredentials = v
|
||||
}
|
||||
if v := os.Getenv("SAXON_CLASSPATH"); v != "" {
|
||||
config.SaxonClasspath = v
|
||||
}
|
||||
return &config, nil
|
||||
}
|
||||
|
||||
@@ -161,7 +164,7 @@ func main() {
|
||||
}
|
||||
|
||||
cmdArgs := []string{
|
||||
"-cp", config.SaxonPath,
|
||||
"-cp", config.SaxonClasspath,
|
||||
"net.sf.saxon.Transform",
|
||||
"-s:" + inputPath,
|
||||
"-xsl:" + xsltPath,
|
||||
|
||||
Reference in New Issue
Block a user