R
Railway•12mo ago
Prentiss

Dockerfile Deployment Error on Railway

Hello, my Dockerfile works find using Docker Desktop, however it fails when deployed to Railway. Error on: RUN go run main.go -precompile Project ID: d09cd450-b0ba-483f-ae0c-5e329305f433
FROM golang:1.21

RUN wget https://github.com/sass/dart-sass/releases/download/1.69.5/dart-sass-1.69.5-linux-x64.tar.gz
RUN tar -xvf dart-sass-1.69.5-linux-x64.tar.gz -C /usr/local/bin --strip-components 1

WORKDIR /go/src

COPY go.mod go.sum ./
RUN go mod download && go mod verify

COPY . .

RUN go run main.go -precompile
RUN CGO_ENABLED=0 GOOS=linux go build -o bin .

FROM scratch

ENV LANG C.UTF-8


COPY --from=0 /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=0 /go/src/bin .
COPY --from=0 /go/src/assets ./assets
COPY --from=0 /go/src/views ./views

CMD ["./bin"]
FROM golang:1.21

RUN wget https://github.com/sass/dart-sass/releases/download/1.69.5/dart-sass-1.69.5-linux-x64.tar.gz
RUN tar -xvf dart-sass-1.69.5-linux-x64.tar.gz -C /usr/local/bin --strip-components 1

WORKDIR /go/src

COPY go.mod go.sum ./
RUN go mod download && go mod verify

COPY . .

RUN go run main.go -precompile
RUN CGO_ENABLED=0 GOOS=linux go build -o bin .

FROM scratch

ENV LANG C.UTF-8


COPY --from=0 /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=0 /go/src/bin .
COPY --from=0 /go/src/assets ./assets
COPY --from=0 /go/src/views ./views

CMD ["./bin"]
10 Replies
Percy
Percy•12mo ago
Project ID: d09cd450-b0ba-483f-ae0c-5e329305f433
Brody
Brody•12mo ago
not sure why you even run the go run main.go -precompile command tbh, ive never done that with my go dockerfiles try removing it?
Prentiss
PrentissOP•12mo ago
It runs a sass compiler prior to the scratch copy.
Brody
Brody•12mo ago
gotta find out what exit status 65 means
Prentiss
PrentissOP•12mo ago
For some reason when building, Railway is not fully copying resources COPY . . prior to calling RUN go run main.go -precompile. This is not occurring on Docker Desktop.
Brody
Brody•12mo ago
something is going wrong when you run precompile, please add debugging information during that process
Prentiss
PrentissOP•12mo ago
Refactored my Dockerfile. It's working now. Thanks for the assistance.
Brody
Brody•12mo ago
no problem 🙂
Want results from more Discord servers?
Add your server