# Golang based Solace client in Docker

**URL:** <https://community.solace.com/t/golang-based-solace-client-in-docker/1344>\
**Category:** Solace Event Broker\
**Tags:** golang\
**Created:** [August 3, 2022, 9:28am UTC](https://community.solace.com/t/golang-based-solace-client-in-docker/1344 "2022-08-03T09:28:48Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![subhoatg](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/subhoatg/32/1004_2.png) [@subhoatg](https://community.solace.com/u/subhoatg)\
**Post date:** [August 3, 2022, 9:28am UTC](https://community.solace.com/t/golang-based-solace-client-in-docker/1344/1 "2022-08-03T09:28:48Z")

</div>

Hi,  
I am trying to create a docker image that would contain the golang based subscriber. The subscriber is based on [https://github.com/SolaceSamples/solace-samples-go/blob/main/patterns/direct\_subscriber.go](https://github.com/SolaceSamples/solace-samples-go/blob/main/patterns/direct_subscriber.go) \>  
The DockerFile looks like the following.  
FROM golang:1.18.0-alpine3.15 as builder

> WORKDIR /app  
> #bring the go project dependencies  
> RUN apk add --update --no-cache ca-certificates git  
> RUN apk add build-base
> 
> # Copy the local package files to the container’s workspace.
> 
> COPY patterns/direct\_subscriber.go ./direct\_subscriber.go  
> COPY go.mod go.sum ./  
> RUN go mod download  
> RUN ls /app
> 
> # RUN go build -o main .
> 
> #build the go project  
> WORKDIR /app  
> RUN CGO\_ENABLED=0 GOOS=linux go build -o main .  
> #main image
> 
> # FROM scratch
> 
> FROM alpine:3.15.2  
> ENV APP\_USER app  
> ENV APP\_HOME /app  
> ENV GROUP\_ID 3000  
> ENV USER\_ID 1000  
> RUN addgroup -g ${GROUP\_ID} -S ${APP\_USER} && adduser -u ${USER\_ID} -S ${APP\_USER} -G ${APP\_USER}  
> RUN mkdir -p $APP\_HOME  
> WORKDIR $APP\_HOME
> 
> # Copy the output from builder image to main image
> 
> COPY --from=builder /app ./  
> RUN chown -R $APP\_USER:$APP\_USER $APP\_HOME  
> USER $APP\_USER
> 
> # Run the sync agent executable by default when the container starts.
> 
> ENTRYPOINT [“./main”]

The docker build fails with the following error.

> ## =\> ERROR [builder 10/10] RUN CGO\_ENABLED=0 GOOS=linux go build -o main .&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0.4s
> 
> ## \> [builder 10/10] RUN CGO\_ENABLED=0 GOOS=linux go build -o main .: #19 0.251 # solace.dev/go/messaging/pkg/solace/subcode #19 0.251 /go/pkg/mod/solace.dev/go/messaging@v1.0.1/pkg/solace/subcode/subcode.go:41:15: undefined: ccsmp.SolClientSubCodeToString #19 0.251 /go/pkg/mod/solace.dev/go/messaging@v1.0.1/pkg/solace/subcode/subcode.go:41:46: undefined: ccsmp.SolClientSubCode #19 0.289 # solace.dev/go/messaging/internal/impl/constants #19 0.289 /go/pkg/mod/solace.dev/go/messaging@v1.0.1/internal/impl/constants/default\_properties.go:35:8: undefined: ccsmp.SolClientSessionPropTopicDispatch #19 0.289 /go/pkg/mod/solace.dev/go/messaging@v1.0.1/internal/impl/constants/default\_properties.go:36:8: undefined: ccsmp.SolClientSessionPropSendBlocking #19 0.289 /go/pkg/mod/solace.dev/go/messaging@v1.0.1/internal/impl/constants/default\_properties.go:37:8: undefined: ccsmp.SolClientSessionPropReapplySubscriptions #19 0.289 /go/pkg/mod/solace.dev/go/messaging@v1.0.1/internal/impl/constants/default\_properties.go:38:8: undefined: ccsmp.SolClientSessionPropIgnoreDupSubscriptionError #19 0.289 /go/pkg/mod/solace.dev/go/messaging@v1.0.1/internal/impl/constants/default\_properties.go:39:8: undefined: ccsmp.SolClientSessionPropReconnectRetries #19 0.289 /go/pkg/mod/solace.dev/go/messaging@v1.0.1/internal/impl/constants/default\_properties.go:40:8: undefined: ccsmp.SolClientSessionPropGuaranteedWithWebTransport #19 0.289 /go/pkg/mod/solace.dev/go/messaging@v1.0.1/internal/impl/constants/default\_properties.go:41:8: undefined: ccsmp.SolClientSessionPropPubWindowSize
> 
> executor failed running [/bin/sh -c CGO\_ENABLED=0 GOOS=linux go build -o main .]: exit code: 2

Could you please help in what could be missing ?

---

<div class="post-metadata">

**Author:** ![amackenzie](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/amackenzie/32/1168_2.png) [@amackenzie](https://community.solace.com/u/amackenzie)\
**Post date:** [August 3, 2022, 2:04pm UTC](https://community.solace.com/t/golang-based-solace-client-in-docker/1344/2 "2022-08-03T14:04:16Z")

</div>

Hi @subhoatg  
Unfortunately, we don’t currently support Alpine, but support will be coming soon in the next version of the Go API! You’ll have to switch to another base image for now such as golang:buster and ubuntu:latest for your build and main images respectively.  
In addition, the Solace PubSub+ Go API uses C code under the hood for performance, thus requires CGO\_ENABLED=1 when building.

---

<div class="post-metadata">

**Author:** ![subhoatg](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/subhoatg/32/1004_2.png) [@subhoatg](https://community.solace.com/u/subhoatg)\
**Post date:** [August 3, 2022, 2:47pm UTC](https://community.solace.com/t/golang-based-solace-client-in-docker/1344/3 "2022-08-03T14:47:13Z")

</div>

@amackenzie \> Thanks for your reply.  
I tried with the below Dockerfile.  
FROM golang:1.18-buster as builder

> WORKDIR /app  
> RUN apt update  
> RUN apt install build-essential -y  
> COPY patterns/direct\_subscriber.go ./direct\_subscriber.go  
> COPY go.mod go.sum ./  
> RUN go mod download  
> RUN ls /app  
> WORKDIR /app  
> RUN CGO\_ENABLED=1 GOOS=linux go build -o main .  
> #main image  
> FROM ubuntu:latest  
> ENV APP\_USER app  
> ENV APP\_HOME /app  
> RUN mkdir -p $APP\_HOME  
> WORKDIR $APP\_HOME
> 
> # Copy the output from builder image to main image
> 
> COPY --from=builder /app ./  
> RUN chown -R $APP\_USER:$APP\_USER $APP\_HOME  
> USER $APP\_USER
> 
> # Run the sync agent executable by default when the container starts.
> 
> ENTRYPOINT [“./main”]

But now I am getting a different error.  
&nbsp;=\> ERROR [builder 10/10] RUN CGO\_ENABLED=1 go build -o main .&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2.3s

> * * *
> 
> ## \> [builder 10/10] RUN CGO\_ENABLED=1 go build -o main .: #18 2.250 # solace.dev/go/messaging/internal/ccsmp #18 2.250 /usr/bin/ld: /go/pkg/mod/solace.dev/go/messaging@v1.0.1/internal/ccsmp/lib/linux/libsolclient.a(solClient.o): Relocations in generic ELF (EM: 62) #18 2.250 /usr/bin/ld: /go/pkg/mod/solace.dev/go/messaging@v1.0.1/internal/ccsmp/lib/linux/libsolclient.a(solClient.o): Relocations in generic ELF (EM: 62) #18 2.250 /usr/bin/ld: /go/pkg/mod/solace.dev/go/messaging@v1.0.1/internal/ccsmp/lib/linux/libsolclient.a(solClient.o): Relocations in generic ELF (EM: 62) #18 2.250 /usr/bin/ld: /go/pkg/mod/solace.dev/go/messaging@v1.0.1/internal/ccsmp/lib/linux/libsolclient.a(solClient.o): Relocations in generic ELF (EM: 62) #18 2.250 /usr/bin/ld: /go/pkg/mod/solace.dev/go/messaging@v1.0.1/internal/ccsmp/lib/linux/libsolclient.a(solClient.o): Relocations in generic ELF (EM: 62) #18 2.250 /usr/bin/ld: /go/pkg/mod/solace.dev/go/messaging@v1.0.1/internal/ccsmp/lib/linux/libsolclient.a(solClient.o): Relocations in generic ELF (EM: 62) #18 2.250 /usr/bin/ld: /go/pkg/mod/solace.dev/go/messaging@v1.0.1/internal/ccsmp/lib/linux/libsolclient.a(solClient.o): Relocations in generic ELF (EM: 62) #18 2.250 /usr/bin/ld: /go/pkg/mod/solace.dev/go/messaging@v1.0.1/internal/ccsmp/lib/linux/libsolclient.a(solClient.o): Relocations in generic ELF (EM: 62) #18 2.250 /usr/bin/ld: /go/pkg/mod/solace.dev/go/messaging@v1.0.1/internal/ccsmp/lib/linux/libsolclient.a(solClient.o): Relocations in generic ELF (EM: 62) #18 2.250 /usr/bin/ld: /go/pkg/mod/solace.dev/go/messaging@v1.0.1/internal/ccsmp/lib/linux/libsolclient.a: error adding symbols: file in wrong format #18 2.250 collect2: error: ld returned 1 exit status
> 
> executor failed running [/bin/sh -c CGO\_ENABLED=1 go build -o main .]: exit code: 2

---

<div class="post-metadata">

**Author:** ![subhoatg](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/subhoatg/32/1004_2.png) [@subhoatg](https://community.solace.com/u/subhoatg)\
**Post date:** [August 3, 2022, 3:29pm UTC](https://community.solace.com/t/golang-based-solace-client-in-docker/1344/4 "2022-08-03T15:29:23Z")

</div>

Update : I previously ran it on an m1 Mac. On an Intel Mac, it is working fine.

---

<div class="post-metadata">

**Author:** ![amackenzie](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/amackenzie/32/1168_2.png) [@amackenzie](https://community.solace.com/u/amackenzie)\
**Post date:** [August 3, 2022, 3:37pm UTC](https://community.solace.com/t/golang-based-solace-client-in-docker/1344/5 "2022-08-03T15:37:00Z")

</div>

That seems like it could do with not supporting M1 Apple chips… yet. Again, it’s coming soon, but we do not yet support M1 chips.

---

<div class="post-metadata">

**Author:** ![subhoatg](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/subhoatg/32/1004_2.png) [@subhoatg](https://community.solace.com/u/subhoatg)\
**Post date:** [August 3, 2022, 3:55pm UTC](https://community.solace.com/t/golang-based-solace-client-in-docker/1344/6 "2022-08-03T15:55:46Z")

</div>

@amackenzie thanks. Do you have any timeline for support of alpine images ?

---

<div class="post-metadata">

**Author:** ![amackenzie](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/amackenzie/32/1168_2.png) [@amackenzie](https://community.solace.com/u/amackenzie)\
**Post date:** [August 3, 2022, 4:07pm UTC](https://community.solace.com/t/golang-based-solace-client-in-docker/1344/7 "2022-08-03T16:07:00Z")

</div>

@murat are you able to comment on the Alpine and M1 timelines?

---

<div class="post-metadata">

**Author:** ![murat](https://avatars.discourse-cdn.com/v4/letter/m/bc8723/32.png) [@murat](https://community.solace.com/u/murat)\
**Post date:** [August 3, 2022, 5:46pm UTC](https://community.solace.com/t/golang-based-solace-client-in-docker/1344/8 "2022-08-03T17:46:19Z")

</div>

Hi @subhoatg ,  
Support of Alpine and M1 will be coming towards the end of this year. I’ll be sure to make a community post when it happens so be in the lookout for that announcement.

---

<div class="post-metadata">

**Author:** ![cpolzer](https://avatars.discourse-cdn.com/v4/letter/c/3bc359/32.png) [@cpolzer](https://community.solace.com/u/cpolzer)\
**Post date:** [February 8, 2023, 10:32am UTC](https://community.solace.com/t/golang-based-solace-client-in-docker/1344/9 "2023-02-08T10:32:41Z")

</div>

Hello,  
may I ask if we are now enabled to use Alpine with MUSL to statically link our dependencies?  
I think static linking with glibc will also cause licencing issues if one plans to distribute a piece of software to customers thats using solace internally ?

---

<div class="post-metadata">

**Author:** ![subhoatg](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/subhoatg/32/1004_2.png) [@subhoatg](https://community.solace.com/u/subhoatg)\
**Post date:** [February 13, 2023, 7:16am UTC](https://community.solace.com/t/golang-based-solace-client-in-docker/1344/10 "2023-02-13T07:16:13Z")

</div>

> [@murat](#):
>
> Hi @subhoatg ,  
> Support of Alpine and M1 will be coming towards the end of this year. I’ll be sure to make a community post when it happens so be in the lookout for that announcement.

Hi @murat  
can you please let us know the status ?

Regards,  
Subhankar

---

<div class="post-metadata">

**Author:** ![murat](https://avatars.discourse-cdn.com/v4/letter/m/bc8723/32.png) [@murat](https://community.solace.com/u/murat)\
**Post date:** [February 13, 2023, 2:55pm UTC](https://community.solace.com/t/golang-based-solace-client-in-docker/1344/11 "2023-02-13T14:55:07Z")

</div>

Hi @subhoatg ,  
We had announced the C API support for Alpine (which is required for the Go API) and that announcement was made here: [PubSub+ Messaging API for C - Alpine Linux Support — Solace Community](https://community.solace.com/discussion/1498/pubsub-messaging-api-for-c-alpine-linux-support)  
As for the Go API it officially supports Alpine Linux as of version 1.1.0 (with the current version being v.1.2.0)  
This concludes support for Alpine, however support for Mac M series is still pending and expected on or before June 2023. Similarly to the the Alpine support, I will be making another community post once it is released for general awareness.  
Thank you,  
MV

---

<div class="post-metadata">

**Author:** ![subhoatg](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/subhoatg/32/1004_2.png) [@subhoatg](https://community.solace.com/u/subhoatg)\
**Post date:** [February 13, 2023, 3:11pm UTC](https://community.solace.com/t/golang-based-solace-client-in-docker/1344/12 "2023-02-13T15:11:39Z")

</div>

Hi @murat

that’s great. I missed the announcement somehow. Do you also have windows support in pipeline ?

---

<div class="post-metadata">

**Author:** ![murat](https://avatars.discourse-cdn.com/v4/letter/m/bc8723/32.png) [@murat](https://community.solace.com/u/murat)\
**Post date:** [February 13, 2023, 3:44pm UTC](https://community.solace.com/t/golang-based-solace-client-in-docker/1344/13 "2023-02-13T15:44:22Z")

</div>

Hi @subhoatg ,  
Support for Windows is in the pipeline, but we do not have any dates that we can share just yet.

Cheers,  
MV
