forked from naskio/docker-strapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
tom_taylor
committed
Oct 23, 2023
1 parent
9d728ee
commit 4136aa6
Showing
4 changed files
with
89 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Creating multi-stage build for production | ||
# This reduces the file size of the docker image for prod | ||
# Also adds ability to change base uri for api | ||
|
||
# BASE | ||
ARG NODE_VERSION=18 | ||
|
||
FROM node:${NODE_VERSION}-alpine as build | ||
RUN apk update && apk add --no-cache build-base gcc autoconf automake zlib-dev libpng-dev vips-dev git > /dev/null 2>&1 | ||
ENV NODE_ENV=production | ||
|
||
ARG STRAPI_VERSION=latest | ||
RUN yarn global add @strapi/strapi@${STRAPI_VERSION} | ||
|
||
RUN mkdir -p /build/app && chown 1000:1000 -R /build/app | ||
|
||
WORKDIR /build | ||
COPY package.json yarn.lock ./ | ||
RUN yarn global add node-gyp | ||
RUN NODE_TLS_REJECT_UNAUTHORIZED=0 yarn config set network-timeout 600000 -g && yarn install --production | ||
ENV PATH /build/node_modules/.bin:$PATH | ||
WORKDIR /build/app | ||
COPY ./server.js ./config/server.js | ||
RUN ls /build/app/config | ||
RUN yarn build | ||
|
||
# Creating final production image | ||
FROM node:${NODE_VERSION}-alpine | ||
RUN apk add --no-cache vips-dev | ||
ENV NODE_ENV=production | ||
RUN mkdir -p /srv/app && chown 1000:1000 -R /srv/app | ||
WORKDIR /srv | ||
COPY --from=build /build/node_modules ./node_modules | ||
WORKDIR /srv/app | ||
COPY --from=build /build/app ./ | ||
ENV PATH /build/node_modules/.bin:$PATH | ||
|
||
RUN chown -R node:node /srv/app | ||
USER node | ||
EXPOSE 1337 | ||
CMD ["yarn", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Strapi v4 | ||
|
||
Based on alpine. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module.exports = ({ env }) => ({ | ||
host: env('HOST', '0.0.0.0'), | ||
port: env.int('PORT', 1337), | ||
url: env("URL", ""), | ||
app: { | ||
keys: env.array('APP_KEYS'), | ||
}, | ||
webhooks: { | ||
populateRelations: env.bool('WEBHOOKS_POPULATE_RELATIONS', false), | ||
}, | ||
}); |