R
Railway•15mo ago
Codemunsta

Deployment issues in Golang project

Project id : 4e543459-a744-4198-970b-be420281426a I am trying to deploy a go lang application, it's services where setup in a docker compose file but i noticed docker compose is not supported yet. So i created a redis and postgres service in my project but after building the deploy logs give this error : github.com/go-redis/redis/v8: /usr/local/go/pkg/tool/linux_amd64/compile: signal: killed failed to build, error: exit status 1
No description
34 Replies
Percy
Percy•15mo ago
Project ID: 4e543459-a744-4198-970b-be420281426a
Brody
Brody•15mo ago
please do not use air when on railway are you using a dockerfile?
Codemunsta
Codemunsta•15mo ago
hey brody, thanks for reaching out. yes i am using a docker file, along with a docker compose .yml file i would remove air now and retry
Brody
Brody•15mo ago
railway doesn't do anything with the compose file, so send me the Dockerfile please
Codemunsta
Codemunsta•15mo ago
No description
Brody
Brody•15mo ago
not very ideal tbh
Codemunsta
Codemunsta•15mo ago
i just tried to tweak it now to remove air and run with go run. however if u can suggest a better one, would be much appreciated
Brody
Brody•15mo ago
working on it
Codemunsta
Codemunsta•15mo ago
thanks how about the services on the docker compose, redis and postgres. that would mean i have to set that up manually? and how so.
Brody
Brody•15mo ago
you said you already added them didnt you?
Codemunsta
Codemunsta•15mo ago
yhh i did, was just confirming if any relative setup would be required after
Brody
Brody•15mo ago
have you added the service variables? https://docs.railway.app/develop/variables#reference-variables
FROM golang:1.20-alpine

WORKDIR /app

COPY go.mod go.sum ./

RUN go mod download

COPY . ./

RUN go build -o main ./...

ENTRYPOINT ["/app/main"]
FROM golang:1.20-alpine

WORKDIR /app

COPY go.mod go.sum ./

RUN go mod download

COPY . ./

RUN go build -o main ./...

ENTRYPOINT ["/app/main"]
the COPY .env .env has been omitted on purpose, you should absolutely not commit your .env file to your repo even if it is a private repo
Codemunsta
Codemunsta•15mo ago
Hello good morning, thanks for assisting. so i have updated the files, the build runs but it fails to connect to the db
Codemunsta
Codemunsta•15mo ago
No description
Brody
Brody•15mo ago
^
Codemunsta
Codemunsta•15mo ago
yes i have
Brody
Brody•15mo ago
please show a screenshot of your service variables
Codemunsta
Codemunsta•15mo ago
No description
Brody
Brody•15mo ago
those are not reference variables, please remove the database related variables and look at the docs page I linked on how to add the reference variables for the database
Codemunsta
Codemunsta•15mo ago
hey, thanks brody. You where a massive help the build works and connects to the db however when i go to the web url it says application failed to respond
Codemunsta
Codemunsta•15mo ago
but the build is working fine
No description
Codemunsta
Codemunsta•15mo ago
hello
Brody
Brody•15mo ago
I was sleeping lol can you send another screenshot of your service variables
Codemunsta
Codemunsta•15mo ago
hey brody lol. yes sleep is very neccessary as developers
Brody
Brody•15mo ago
sometimes
Codemunsta
Codemunsta•15mo ago
so fixed it now, something to do with having to make provisions for the port railway way listens for your app but you have really been a humongous help. I am very grateful my senior dev
Brody
Brody•15mo ago
I'm glad it's working, but I'd like to make sure you do have the variables setup correctly, even if they are working would you mind sending a screenshot of your service variables
Codemunsta
Codemunsta•15mo ago
alright, let me get a screenshot
Codemunsta
Codemunsta•15mo ago
No description
Brody
Brody•15mo ago
perfect! I always want people to use reference variables because they will auto update if you where to for instance regen your database credentials, without reference variables you'd need to manually copy them back over
Codemunsta
Codemunsta•15mo ago
yayyyhh!!😆
Brody
Brody•15mo ago
well all solved then, happy coding fellow go dev!
Codemunsta
Codemunsta•15mo ago
you are very right. makes it more straightfoward instead of manually updating it once again Thank you my senior Go dev
Brody
Brody•15mo ago
no problem 🙂
Want results from more Discord servers?
Add your server