Reputation: 75
I have some issue with the libiconv "translit" option using the library https://github.com/djimenez/iconv-go in a alpine 3.20 image
here the go code to reproduce :
main.go
package main
import (
"fmt"
iconv "github.com/djimenez/iconv-go"
)
func main() {
output := make([]byte, 20)
nRead, nWrite, err := iconv.Convert([]byte("éé"), output, "UTF-8", "ASCII//TRANSLIT")
fmt.Println(nRead, nWrite, err)
}
go.mod
module truc
go 1.22.4
require github.com/djimenez/iconv-go v0.0.0-20160305225143-8960e66bd3da // indirect
Dockerfile
FROM golang:1.22-alpine3.20 as builder
RUN apk --no-cache add build-base gnu-libiconv-libs
WORKDIR /src
#copy go mod and run go get to hit cache if no new deps
COPY ./go.* ./
RUN go mod download
COPY . .
RUN go build -o "test-iconv" .
FROM alpine:3.20 as runtime
RUN apk --no-cache add gnu-libiconv-libs
COPY --from=builder /src/test-iconv /app/
RUN adduser connector --disabled-password && chown connector. -R /app && chmod 700 "/app/test-iconv"
USER connector
#entrypoint
ENTRYPOINT ["/app/test-iconv"]
then launch :
docker build . -t test-iconv && docker run test-iconv
I want the output 4 2 nil, but i got :
0 0 invalid argument
if i switch the builder and runtime image to ubuntu based golang:1.22, the problem disapear, but the image is now much bigger (800MB instead of 18MB)...
What am i missing in alpine way ?
Thank you.
Upvotes: 2
Views: 59