Skip to content

Build step in dockerfile #6

@mifsudc

Description

@mifsudc

medusa build outputs a standalone transpiled output, and isn't strictly required by medusa start, which serves straight from the typescript source files.

For production builds, if we want to minimize the size of the docker image we can update the dockerfile to use the transpiled output:

FROM node:20 AS builder

WORKDIR /app

COPY medusa-config.ts package.json yarn.lock ./

RUN yarn install

COPY . ./

RUN yarn build

WORKDIR /app/.medusa/server

RUN yarn install --production

FROM node:20-slim

WORKDIR /app

COPY --from=builder /app/.medusa/server ./

COPY ./docker-entrypoint.sh ./

RUN chmod +x ./docker-entrypoint.sh

ENTRYPOINT [ "./docker-entrypoint.sh" ]

CMD ["start"]

For non-development builds, or if we don't care about image size we can ignore it entirely:

FROM node:20-slim

WORKDIR /app

COPY docker-entrypoint.sh ./

RUN chmod +x ./docker-entrypoint.sh

COPY . ./

RUN yarn install

ENTRYPOINT ["./docker-entrypoint.sh"]

CMD ["develop"]

(My environment has a local medusa project, but you can sub the git clone in as required if no changes are required to the medusa setup)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions