add docker and docker-compose
This commit is contained in:
51
Dockerfile.dev
Normal file
51
Dockerfile.dev
Normal file
@@ -0,0 +1,51 @@
|
||||
ARG NODE_VERSION=20
|
||||
ARG NODE_ENV=production
|
||||
|
||||
FROM node:${NODE_VERSION}-alpine
|
||||
|
||||
ARG UID=1000
|
||||
ARG GID=1000
|
||||
|
||||
WORKDIR /server
|
||||
|
||||
# Install dependencies for native modules
|
||||
RUN apk add --no-cache python3 make g++ git
|
||||
|
||||
# Enable Corepack
|
||||
RUN corepack enable && corepack prepare yarn@3.2.1 --activate
|
||||
|
||||
# Create non-root user (remove default node user if it conflicts)
|
||||
RUN deluser --remove-home node 2>/dev/null || true && \
|
||||
addgroup -g ${GID} medusa && \
|
||||
adduser -D -u ${UID} -G medusa medusa && \
|
||||
chown medusa:medusa /server
|
||||
|
||||
# Switch to non-root user
|
||||
USER medusa
|
||||
|
||||
# Copy dependency files first for better caching
|
||||
COPY --chown=medusa:medusa package.json yarn.lock .yarnrc.yml ./
|
||||
COPY --chown=medusa:medusa .yarn .yarn
|
||||
COPY --chown=medusa:medusa packages packages
|
||||
|
||||
# Install all dependencies (including devDependencies)
|
||||
RUN yarn install
|
||||
|
||||
# Copy remaining files
|
||||
COPY --chown=medusa:medusa . .
|
||||
|
||||
# Build packages
|
||||
RUN yarn build
|
||||
|
||||
# Build draft-order plugin admin extensions
|
||||
RUN cd packages/plugins/draft-order && npx medusa plugin:build
|
||||
|
||||
EXPOSE 9000 5173
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
|
||||
CMD wget -q --spider http://localhost:9000/health || exit 1
|
||||
|
||||
LABEL org.opencontainers.image.description="Medusa Commerce Platform (Dev)"
|
||||
|
||||
ENTRYPOINT []
|
||||
CMD ["./start.sh"]
|
||||
Reference in New Issue
Block a user