Skip to content

Commit

Permalink
fix: optimize strapi dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
devthejo committed Jun 19, 2023
1 parent 1160b8b commit 83cd690
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions back-strapi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,29 @@ ENV PATH $NODE_HOME/bin:$PATH
RUN curl https://nodejs.org/dist/v$NODE_VERSION/$NODE_PACKAGE.tar.gz | tar -xzC /opt/
RUN npm i -g yarn

RUN apt-get update
RUN apt-get install -y libnss3 ca-certificates fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 \
RUN apt-get update && apt-get install -y libnss3 ca-certificates fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 \
libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 \
libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 \
libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils
libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils && \
rm -rf /var/lib/apt/lists/*

WORKDIR /app
RUN adduser --uid 1001 strapi

COPY . .
EXPOSE 1337

RUN yarn install --production --frozen-lockfile --prefer-offline
RUN yarn cache clean
USER 1001

ENV NODE_ENV production
WORKDIR /app

RUN yarn build
CMD ["yarn", "start"]

EXPOSE 1337
COPY --chown=1001:1001 package.json yarn.lock ./

RUN adduser --uid 1001 strapi && \
chown -R strapi:strapi /app
USER 1001
RUN yarn install --production --frozen-lockfile --prefer-offline && \
yarn cache clean

ENV NODE_ENV production

CMD ["yarn", "start"]
COPY --chown=1001:1001 . .

RUN yarn build

0 comments on commit 83cd690

Please sign in to comment.