#Go Deploy Gone Wrong

38 messages · Page 1 of 1 (latest)

runic steppe
#

Hey all, need a sanity check on a failing deploy. I am able to build and run my app locally just fine with my Dockerfile but it fails when I attempt to deploy on Railway. Interestingly, I have used the exact same project structure and Dockerfile to deploy an app to Railway before too.

chrome portalBOT
#

Project ID: 3a924444-5f7c-477b-a993-438ff0417e6d

sick thistleBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

runic steppe
#

3a924444-5f7c-477b-a993-438ff0417e6d

#

service id: f4b778dc-aa7e-4d96-acf0-53e538f72d79

unborn comet
#

what a title lol

#

send the dockerfile please?

#

would you mind wrapping that in triple backticks

runic steppe
#

ofc...

# Use the specific Go 1.20 image as the base image
FROM golang:1.20

# Set the working directory inside the container
WORKDIR /app

# Copy the Go module files to the working directory
COPY go.mod go.sum ./

# Download the Go module dependencies
RUN go mod download

# Copy the rest of the application source code to the working directory
COPY . .

# Build the Go application
RUN go build -o colosseum ./internal/cmd/colosseum

# Set the port number that the container should expose
ENV PORT 8080

# Expose the port on which the application will listen
EXPOSE $PORT

# Set the command to run when the container starts
CMD ["./colosseum"]
unborn comet
#

yeah that looks like a perfectly good dockerfile, very similar to the one I use, what exactly is failing?

runic steppe
#
 [6/6] RUN go build -o colosseum ./internal/cmd/colosseum:

0.294 stat /app/internal/cmd/colosseum: directory not found

-----
unborn comet
#

wanna try ./... instead of that path?

runic steppe
#

to clarify

RUN go build -o colosseum ./...

?

unborn comet
#

yep

runic steppe
#

hmmm

#9 [5/6] COPY . .
#9 DONE 0.0s

#10 [6/6] RUN go build -o colosseum ./...

#10 0.698 go: cannot write multiple packages to non-directory colosseum

#10 ERROR: process "/bin/sh -c go build -o colosseum ./..." did not complete successfully: exit code: 1
#

yeah its a weird one

unborn comet
#

I'm hmmm'ing too

runic steppe
#

appreciate the quick response, FWIW, I have tried things like deleting the project/service in case there was some weird caching of the context etc but no luck

unborn comet
#

would you mind sharing your repo?

#

or maybe a minimal reproducible example repo?

runic steppe
#

I wouldn't be able to share the repo but I can promise that the structure is correct

e.g:

├── internal

│   ├── cmd
│   │   └── colosseum
│   │       └── main.go


unborn comet
#

maybe it's because you have a folder named colosseum and are trying to output the binary as colosseum too

#

change the output bin to just app or something

runic steppe
#

🤞

#

Dang, I tried

ls -la /app/internal/cmd && ls -la /app/internal/cmd/colosseum

inside the Dockerfile and somehow that dir is actually not there, super weird but nothing in the dockerignore and works just fine locally...

unborn comet
#

I'm not just saying this, but that was my first thought, I really don't know why I didn't say anything

#

also, why dockerignore instead of just a .gitignore, do you have things you want in the repo and not in the image?

runic steppe
#

I was using the railway cli to test, does that also ignore .gitignore when building? (wasn't sure) but I see your point, but just for sanity, I removed both but the issue remains

unborn comet
#

the cli will omit tarballing files/folders based on rules in either a .gitignore or a .railwayignore file

runic steppe
#

ah nice, good to know

unborn comet
#

I know you've shown me a tree, but if you'd provide me with a repo that has a minimal reproducible example, id be happy to debug it myself too

runic steppe
#

Will do, let me try and put something together!

unborn comet
#

sounds good

runic steppe
#

of course the repro attempt actually works RIP

unborn comet
#

lmao make it not work

runic steppe
#

Alright will take some time to chew on this and see if I can see whats up, I'll be sure to update you on here if I do figure it out or if I don't

#

Once again, appreciate your help so far