How does redeploying work?

I have a RedwoodJs app that I deployed successfully. I noticed my Redwood “scripts” folder was getting copied so I updated my Dockerfile to COPY scripts scripts and then ran fly deploy but I don’t see the scripts folder getting copied? Is there another command I am missing?

The fly deploy should simply build an image based on the Dockerfile. Couple of random thoughts:

  1. If you have docker locally, you could try a local build and see what’s in that. Saves wasting time deploying to Fly if it’s not going to work
  2. Check your .dockerignore and see if that folder is being ignored, and hence won’t be there to be copied in the Dockerfile

Nothing in my ignore file besides the node_modules folder. After I deploy I fly ssh console into my app and check for the folder’s existence. Is this correct a correct way to verify the folder was copied?

Ok, it’s not the .dockerignore then. Hmm … strange.

Yes, if you connect to the VM using fly ssh console and see the folder is not there, it can’t be part of the image. Else it would be there.

Could it be the path to the scripts folder, on either end? I believe if you do COPY abc xyz then the “abc” folder would need to be a sibling of the Dockerfile at your end (in your local folder or repo). And I assume the “xyz” is relative to the WORKDIR value at the image’s end. So, whether the scripts folder is either not found at your end so not being coped, or it is found and is being coped, but to a folder you are not expecting it to be in. Not sure I’m afraid.

If you like you could post your Dockerfile? Someone else may be able to spot an issue.

1 Like

Here’s my Dockerfile. I added COPY scripts scripts between the copy of api and web which both work.

ARG BASE_IMAGE=node:16.13.0-alpine
FROM ${BASE_IMAGE} as base

RUN mkdir /app
WORKDIR /app

# Required for building the api and web distributions
ENV NODE_ENV development

FROM base as dependencies

COPY .yarn .yarn
COPY .yarnrc.yml .yarnrc.yml
COPY package.json package.json
COPY web/package.json web/package.json
COPY api/package.json api/package.json
COPY yarn.lock yarn.lock

RUN --mount=type=cache,target=/root/.yarn/berry/cache \
    --mount=type=cache,target=/root/.cache yarn install --immutable

COPY redwood.toml .
COPY graphql.config.js .

FROM dependencies as web_build

COPY web web
RUN yarn rw build web

FROM dependencies as api_build

COPY scripts scripts

COPY api api
RUN yarn rw build api

FROM dependencies

ENV NODE_ENV production

COPY --from=web_build /app/web/dist /app/web/dist
COPY --from=api_build /app/api /app/api
COPY --from=api_build /app/node_modules/.prisma /app/node_modules/.prisma

COPY .fly .fly

ENTRYPOINT ["sh"]
CMD [".fly/start.sh"]

Hmm. Well I’m not sure but from a quick glance, I see you (now) have

COPY scripts scripts
COPY api api

but don’t then copy it below. You appear to only have:

COPY --from=api_build /app/api /app/api

Wouldn’t you also need a scripts line? Like:

COPY --from=api_build /app/scripts /app/scripts
COPY --from=api_build /app/api /app/api

? Assuming /api and /scripts are indeed siblings. Knowing nothing about your app structure here - that could be entirely wrong :slight_smile:

Thanks Greg for your help. I know nothing about Docker and just assumed all I needed was the single COPY line. My app is a RedwoodJS application and it has /api, /web, /scripts at the root. I will add the line you suggested and read up a bit more about docker and give it another go.

1 Like