Closed afernandezod closed 1 year ago
Here the Dockerfile that runs as part of the deployment process:
FROM 729964090428.dkr.ecr.us-east-1.amazonaws.com/compliant/golang1.14.7-alpine:latest AS builder
WORKDIR /go/src/rtt-event-handler-go-service COPY . /go/src/rtt-event-handler-go-service
RUN go env -w GOPRIVATE=github.com/xxxxxxxxxx RUN go env -w GOPROXY=direct RUN CGO_ENABLED=0 go build -mod=vendor -o /go/src/rtt-event-handler-go-service/frontend
FROM 729964090428.dkr.ecr.us-east-1.amazonaws.com/ecom-arch/alpine-aws:latest
ENV GIN_MODE release WORKDIR /go/src/rtt-event-handler-go-service COPY --from=builder /go/src/rtt-event-handler-go-service/frontend . COPY --from=builder /go/src/rtt-event-handler-go-service/resources ./resources EXPOSE 8080 ENTRYPOINT ["./frontend"
try GOOS=linux GOARCH=amd64 go build Here is my DockerFile that I use on my Mac
FROM golang:1.14 AS builder
COPY resources/9.2.0.1-IBM-MQC-Redist-LinuxX64.tar /opt/mqm/
RUN mkdir -p /opt/mqm && cd /opt/mqm \
&& tar -xvf ./*.tar \
&& rm -f ./*.tar
ADD resources/Root_CA.crt /etc/ssl/certs/
WORKDIR /go/src/app
COPY . .
RUN go get -d -v ./...
RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o bin/go-mq-gateway ./cmd/mq-gateway
FROM ubuntu:20.04
COPY --from=builder /go/src/app/bin/go-mq-gateway /go/src/app/bin/go-mq-gateway
COPY --from=builder /opt/mqm/lib /opt/mqm/lib
COPY --from=builder /opt/mqm/lib64 /opt/mqm/lib64
COPY /configs/application.yml /deployments/config/application.yml
RUN chmod +x /go/src/app/bin/go-mq-gateway
ENTRYPOINT ["/go/src/app/bin/go-mq-gateway","-c","/deployments/config/application.yml", "-l","info"]
@Ivansamara109 thanks for your comment, I have to recognize I am very poor equipped in docker script and I can't easily recognize what need to stay or what need to be changed based on your recommendation.
In an intuitive way, I know what is happening: the "machine" or instance created by Docker-container doesn't have the /opt/mqm/ files to build against but I don't know how to include and resolve that dependency in the script.
What you are saying I should replace :
RUN CGO_ENABLED=0 go build -mod=vendor -o /go/src/rtt-event-handler-go-service/frontend
By:
RUN go get -d -v ./... RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /go/src/rtt-event-handler-go-service/frontend
?
Once again, Thanks.
Why are you disabling CGO? The code needs to be compiled against the C client libraries, as it states in the documentation. I also wouldn't use alpine as the basis for the container as its use of a different libc means it won't work.
mq-golang V5
my app run perfect in my local (MAC), when I try to deploy to DEV building Docker container it fails in that step:
19:26:19 Step 6/13 : RUN CGO_ENABLED=0 go build -mod=vendor -o /go/src/rtt-event-handler-go-service/frontend 19:26:19 ---> Running in a97f68f67bd1 19:26:21 [91m# rtt-event-handler-go-service/mq 19:26:21 mq/mq.go:11:15: undefined: ibmmq.MQQueueManager 19:26:21 mq/mq.go:22:52: undefined: ibmmq.MQQueueManager 19:26:21 mq/mq.go:27:9: undefined: ibmmq.NewMQCNO 19:26:21 mq/mq.go:28:8: undefined: ibmmq.NewMQCD 19:26:21 mq/mq.go:29:9: undefined: ibmmq.NewMQCSP 19:26:21 mq/mq.go:58:19: undefined: ibmmq.MQQueueManager 19:26:21 mq/mq.go:58:63: undefined: ibmmq.MQObject 19:26:21 mq/mq.go:77:18: undefined: ibmmq.MQObject 19:26:21 mq/mq.go:97:19: undefined: ibmmq.MQObject 19:26:21 mq/mq.go:108:22: undefined: ibmmq.MQQueueManager 19:26:21 mq/mq.go:11:15: too many errors
I am pretty sure there is something missing in the Dockerfile (docker Script) but no idea what need to be added. Perhaps I need yo download the git copy from GIT but don't know how. (git clone https://github.com/ibm-messaging/mq-golang.git src/github.com/ibm-messaging/mq-golang), the will need to build the ibmmq package against those objects.
I looked into the Dockerfile samples and did not identify a step that will help with my issue.
I checked my mchine and /opt/mqm exist and I believe has all files.
Wondering if anyone could assist.
Thanks.