go-tarantool
go-tarantool copied to clipboard
Not work in docker container
Sorry, I can't reopen the #315 issue.
Unfortunately, nothing helped.
- If run the application
go run ./main.go -tags go_tarantool_ssl_disable
- the same errors.
- If install opensll to golang:1.20-alpine container - the same errors Dockerfile
FROM golang:1.20-alpine
WORKDIR "/usr/src/tarantool"
RUN apk add --update openssl && \
rm -rf /var/cache/apk/*
- If build a custom container from ubuntu:latest - the same errors Dockerfile
FROM ubuntu:latest
WORKDIR "/usr/src"
RUN apt-get update \
&& apt-get -y install \
wget \
tar \
openssl \
ca-certificates \
libssl-dev \
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
RUN update-ca-certificates -v
RUN wget https://go.dev/dl/go1.20.6.linux-amd64.tar.gz \
&& tar -C /opt -xzf go1.20.6.linux-amd64.tar.gz
ENV PATH="$PATH:/opt/go/bin"
I'll check the docker images in a few days.
I'm sorry, you need to run the application with the command if you don't need OpenSSL/TLS support:
go run -tags go_tarantool_ssl_disable ./main.go
instead of:
go run ./main.go -tags go_tarantool_ssl_disable
For the future generations: I've had similar issue using
go build -tags go_tarantool_ssl_disable -tags go_tarantool_call_17
instead of
go build -tags go_tarantool_ssl_disable,go_tarantool_call_17
It really hard to distinct invalid tag setup from tags not working in Go.
@DifferentialOrange If I want to user ssl in docker container, how I should fix it?
@DifferentialOrange If I want to user ssl in docker container, how I should fix it?
You need to install OpenSSL + dev files for compilation into the image before build.
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS build
WORKDIR /build
COPY . .
RUN alpk update && apk add openssl && \
go build -o ./bin/app ./cmd/...
# github.com/tarantool/go-openssl
vendor/github.com/tarantool/go-openssl/net.go:25:7: undefined: Ctx
vendor/github.com/tarantool/go-openssl/net.go:44:43: undefined: Ctx
vendor/github.com/tarantool/go-openssl/net.go:52:41: undefined: Ctx
vendor/github.com/tarantool/go-openssl/net.go:80:38: undefined: Ctx
vendor/github.com/tarantool/go-openssl/net.go:80:62: undefined: Conn
vendor/github.com/tarantool/go-openssl/net.go:90:68: undefined: Ctx
vendor/github.com/tarantool/go-openssl/net.go:91:21: undefined: Conn
vendor/github.com/tarantool/go-openssl/net.go:109:45: undefined: Ctx
vendor/github.com/tarantool/go-openssl/net.go:110:20: undefined: Conn
vendor/github.com/tarantool/go-openssl/net.go:115:59: undefined: Ctx
vendor/github.com/tarantool/go-openssl/net.go:115:59: too many errors
I think you don't install header files for the OpenSSL or a C compiler or something wrong with the environment. We have an example how to build OpenSSL, but on CI, not inside a docker image:
https://github.com/tarantool/tt/blob/5fea6e16448598c67afa534e93010f4b1d2f70ae/.github/workflows/publish.yml#L31-L37 https://github.com/tarantool/tt/blob/5fea6e16448598c67afa534e93010f4b1d2f70ae/.github/workflows/publish.yml#L61-L67
But it could help.
I showed above an example of how I build custom docker container. Everything that is needed is installed in it (openssl, libssl-dev) , but at startup it still has the same errors. If install samething on a virtual machine with the same options, then there are no errors. This is clearly a problem when working with a docker container. I took the advice and start program with the go_tarantool_ssl_disable tag. Everything works without problems.