Skip to content

Commit

Permalink
refactor(deployment): serve frontend from backend, making proxy redun…
Browse files Browse the repository at this point in the history
…dant (#278)
  • Loading branch information
rielas committed Mar 3, 2024
1 parent 216342e commit 7a240d8
Show file tree
Hide file tree
Showing 621 changed files with 120 additions and 151 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# compiled output
/dist
/public/build
/client/build
/node_modules

# Logs
Expand Down
90 changes: 75 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,87 @@
FROM node:14
###################
# BUILD FOR LOCAL DEVELOPMENT
###################

WORKDIR /var/www/
FROM node:14-alpine As development

COPY package*.json ./
WORKDIR /usr/src/app

RUN npm ci -q
COPY --chown=node:node package*.json ./
COPY --chown=node:node tsconfig.build.json ./
COPY --chown=node:node tsconfig.json ./
COPY --chown=node:node nest-cli.json ./
COPY --chown=node:node mikro-orm.config.ts ./
COPY --chown=node:node .env ./
COPY --chown=node:node config ./config
COPY --chown=node:node keycloak ./keycloak
COPY --chown=node:node client ./client
COPY --chown=node:node src ./src

COPY config ./config
COPY tsconfig.build.json ./
COPY tsconfig.json ./
COPY nest-cli.json ./
COPY .env ./
COPY src ./src

RUN apk add --no-cache --virtual .gyp python3 py3-pip make g++

RUN npm ci
RUN npm ci --prefix=client --only=prod

RUN apk del .gyp

USER node

###################
# BUILD FOR PRODUCTION
###################

FROM node:14-alpine As build

WORKDIR /usr/src/app

COPY --chown=node:node package*.json ./
COPY --chown=node:node tsconfig.build.json ./
COPY --chown=node:node tsconfig.json ./
COPY --chown=node:node nest-cli.json ./
COPY --chown=node:node mikro-orm.config.ts ./
COPY --chown=node:node .env ./
COPY --chown=node:node config ./config
COPY --chown=node:node keycloak ./keycloak
COPY --chown=node:node client ./client
COPY --chown=node:node src ./src

COPY --chown=node:node --from=development /usr/src/app/node_modules ./node_modules
COPY --chown=node:node --from=development /usr/src/app/client/node_modules ./client/node_modules

RUN apk add --no-cache --virtual .gyp python3 py3-pip make g++

RUN npm run build
RUN npm prune --production
RUN npm run build --prefix=client

ENV NODE_ENV production

RUN npm ci --only=production && npm cache clean --force

RUN chown -R node:node /var/www/*
RUN apk del .gyp

USER node

ENV NODE_ENV=production
###################
# PRODUCTION
###################

FROM node:14-alpine As production

WORKDIR /usr/src/app

COPY --chown=node:node nest-cli.json ./
COPY --chown=node:node mikro-orm.config.ts ./
COPY --chown=node:node .env ./
COPY --chown=node:node config ./config
COPY --chown=node:node keycloak ./keycloak

COPY --chown=node:node --from=build /usr/src/app/node_modules ./node_modules
COPY --chown=node:node --from=build /usr/src/app/package*.json ./
COPY --chown=node:node --from=build /usr/src/app/dist ./dist

EXPOSE 3000
COPY --chown=node:node --from=build /usr/src/app/client/node_modules ./client/node_modules
COPY --chown=node:node --from=build /usr/src/app/client/package*.json ./client/
COPY --chown=node:node --from=build /usr/src/app/client/build ./client/build

CMD ["npm", "run", "start:prod"]
CMD ["npm", "run", "start:prod"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion public/package.json → client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"react-owl-carousel": "^2.3.3",
"react-router-dom": "^5.2.0",
"web-vitals": "^0.2.4",
"xmldom": "^0.6.0"
"xmldom": "^0.6.0",
"react-scripts": "4.0.3"
},
"scripts": {
"cypress:run": "cypress open --browser chrome",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
Loading

0 comments on commit 7a240d8

Please sign in to comment.