opt dckr
deploy to danak / build_and_deploy (push) Has been cancelled

This commit is contained in:
2026-06-25 18:08:45 +03:30
parent 494c2e7b8f
commit e87f50ca7a
2 changed files with 39 additions and 17 deletions
+17
View File
@@ -0,0 +1,17 @@
node_modules
dist
coverage
.git
.github
.env
.env.*
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.vscode
.idea
.DS_Store
*.md
Dockerfile*
docker-compose*
+22 -17
View File
@@ -1,37 +1,42 @@
FROM node:20-alpine AS base FROM node:20-alpine AS base
ENV TZ=Asia/Tehran
RUN apk add --no-cache tzdata RUN apk add --no-cache tzdata
# Set the timezone to Asia/Tehran
RUN cp /usr/share/zoneinfo/Asia/Tehran /etc/localtime && echo "Asia/Tehran" > /etc/timezone
FROM base AS deps FROM base AS deps
WORKDIR /temp-deps WORKDIR /app
COPY package*.json ./ RUN corepack enable
RUN yarn install COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
FROM base AS builder FROM base AS builder
WORKDIR /build WORKDIR /app
COPY . ./ RUN corepack enable
COPY --from=deps /temp-deps/node_modules ./node_modules COPY package.json yarn.lock nest-cli.json tsconfig.json tsconfig.build.json ./
COPY --from=deps /app/node_modules ./node_modules
COPY src ./src
RUN yarn build \
&& mkdir -p dist/config \
&& cp src/config/swagger.json dist/config/
# Check if a build script exists and run the build if it does FROM base AS prod-deps
RUN if [ -f package.json ] && grep -q '"build":' package.json; then yarn build; fi WORKDIR /app
RUN corepack enable
COPY package.json yarn.lock ./
RUN yarn install --production --frozen-lockfile RUN yarn install --production --frozen-lockfile
FROM base AS runner FROM base AS runner
RUN addgroup -S appgroup && adduser -S appuser -G appgroup RUN addgroup -S appgroup && adduser -S appuser -G appgroup
WORKDIR /app WORKDIR /app
COPY --from=builder /build ./ ENV NODE_ENV=production
RUN chown -R appuser:appgroup /app COPY --from=prod-deps --chown=appuser:appgroup /app/node_modules ./node_modules
COPY --from=builder --chown=appuser:appgroup /app/dist ./dist
COPY --from=builder --chown=appuser:appgroup /app/package.json ./package.json
USER appuser USER appuser
ENV NODE_ENV=production
EXPOSE 3000 EXPOSE 3000
CMD ["npm", "start"] CMD ["node", "dist/main"]