How i can deploy a Medusajs backend on fly.io?

Im trying to do it but im getting this error

Validating C:\DATA - JUAN ELIAS JABIB\developer\lafincadelbarrio.com-backend\fly.toml
✓ Configuration is valid
==> Building image
Remote builder fly-builder-bitter-bush-859 ready
Remote builder fly-builder-bitter-bush-859 ready
==> Building image with Docker
--> docker host: 24.0.7 linux x86_64
[+] Building 1.6s (11/16)
 => [internal] load build definition from Dockerfile                                                                                0.5s
 => => transferring dockerfile: 1.11kB                                                                                              0.5s 
 => [internal] load .dockerignore                                                                                                   0.5s
 => => transferring context: 315B                                                                                                   0.5s 
 => resolve image config for docker.io/docker/dockerfile:1                                                                          0.3s
 => CACHED docker-image://docker.io/docker/dockerfile:1@sha256:dbbd5e059e8a07ff7ea6233b213b36aa516b4c53c645f1817a4dd18b83cbea56     0.0s
 => [internal] load metadata for docker.io/library/node:18.18.0-slim                                                                0.1s 
 => [internal] load build context                                                                                                   0.5s
 => => transferring context: 16.62kB                                                                                                0.5s 
 => CANCELED [base 1/3] FROM docker.io/library/node:18.18.0-slim@sha256:a2598120308db34b12278f10a694ae0073e492cc9b98bae471543b90ee  0.5s 
 => => resolve docker.io/library/node:18.18.0-slim@sha256:a2598120308db34b12278f10a694ae0073e492cc9b98bae471543b90eeabee73          0.0s 
 => => sha256:8d6134753fa4bc1d3b2dd23e1e32c484b8c6bddbe09f60125aad8026fa4b1d91 1.37kB / 1.37kB                                      0.0s 
 => => sha256:23dc5851ef98f10d3b60da9447b22c661093d2cbfe31423274a46af1f4253d0b 7.07kB / 7.07kB                                      0.0s 
 => => sha256:a803e7c4b030119420574a882a52b6431e160fceb7620f61b525d49bc2d58886 29.12MB / 29.12MB                                    0.3s 
 => => sha256:1422c0cc5b325dd28b77dd39b681d0acfa5bf4675f3bdc5fb027d8139b6c2963 3.36kB / 3.36kB                                      0.0s 
 => => sha256:8887fcd01c49e73241f4896685b93bfbc19a7b3ab18d99c13c85d52701461d0d 46.43MB / 46.43MB                                    0.6s 
 => => sha256:fceadc94b0d142b244590b5b122e9467723aa9c04bf5daa2b42c81e8dd5562fb 2.74MB / 2.74MB                                      0.1s
 => => sha256:19ba7b5ec1adac0807e4b1cce01183a59f91f7e667015b3f05ad04237c798a76 452B / 452B                                          0.0s 
 => => sha256:a2598120308db34b12278f10a694ae0073e492cc9b98bae471543b90eeabee73 1.21kB / 1.21kB                                      0.0s 
 => => extracting sha256:a803e7c4b030119420574a882a52b6431e160fceb7620f61b525d49bc2d58886                                           0.3s 
 => CACHED [base 2/3] WORKDIR /app                                                                                                  0.0s 
 => CACHED [base 3/3] RUN npm install -g yarn@1.22.19 --force                                                                       0.0s 
 => CACHED [build 1/6] RUN apt-get update -qq &&     apt-get install --no-install-recommends -y build-essential node-gyp pkg-confi  0.0s 
 => ERROR [build 2/6] COPY --link .yarnrc.yml package.json yarn.lock ./                                                             0.0s 
------
 > [build 2/6] COPY --link .yarnrc.yml package.json yarn.lock ./:
------
Error: failed to fetch an image or build from source: error building: failed to solve: failed to compute cache key: failed to calculate checksum of ref 255408d2-d592-465c-94aa-cc77cd43515b::8mn2sgu2lgvujigiluf3fbkqq: "/yarn.lock": not found

What can be?

Hey Juan

Any chance you could share the Dockerfile and/or repo you’re deploying from? Having a look at your error it seems like the yarn.lock file is missing from the directory you’re deploying your app from.

Sure mate,

this is my dockerfile

# syntax = docker/dockerfile:1

# Adjust NODE_VERSION as desired
ARG NODE_VERSION=18.18.0
FROM node:${NODE_VERSION}-slim as base

LABEL fly_launch_runtime="Node.js"

# Node.js app lives here
WORKDIR /app

# Set production environment
ENV NODE_ENV="production"
ARG YARN_VERSION=1.22.19
RUN npm install -g yarn@$YARN_VERSION --force


# Throw-away build stage to reduce size of final image
FROM base as build

# Install packages needed to build node modules
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3

# Install node modules
COPY --link .yarnrc.yml package.json yarn.lock ./
RUN yarn install --frozen-lockfile --production=false

# Copy application code
COPY --link . .

# Build application
RUN yarn run build

# Remove development dependencies
RUN yarn install --production=true


# Final stage for app image
FROM base

# Copy built application
COPY --from=build /app /app

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "yarn", "run", "start" ]


It looks like medusa starter has yarn.lock in gitignore: medusa-starter-default/.gitignore at master · medusajs/medusa-starter-default · GitHub

We default to basing your .dockeringore file on the contents of .gitignore.

Try removing the line yarn.lock from .dockerignore and deploying again.

Thanks fpor the help, that was the solution!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.