Add build watching for backend project
This commit is contained in:
parent
0e684a69be
commit
8e855fd454
7 changed files with 6868 additions and 33 deletions
|
@ -1,28 +1,15 @@
|
|||
# Check out https://hub.docker.com/_/node to select a new base image
|
||||
FROM node:16-slim
|
||||
|
||||
# Set to a non-root built-in user `node`
|
||||
USER node
|
||||
|
||||
# Create app directory (with user `node`)
|
||||
RUN mkdir -p /home/node/app
|
||||
|
||||
WORKDIR /home/node/app
|
||||
|
||||
# Install app dependencies
|
||||
# A wildcard is used to ensure both package.json AND package-lock.json are copied
|
||||
# where available (npm@5+)
|
||||
COPY --chown=node package*.json ./
|
||||
EXPOSE 4200
|
||||
|
||||
RUN npm install
|
||||
ENTRYPOINT [ "/docker.sh" ]
|
||||
CMD [ "run" ]
|
||||
|
||||
# Bundle app source code
|
||||
COPY --chown=node . .
|
||||
|
||||
RUN npm run build
|
||||
|
||||
# Bind to all network interfaces so that it can be mapped to the host OS
|
||||
ENV HOST=0.0.0.0 PORT=3000
|
||||
|
||||
EXPOSE ${PORT}
|
||||
CMD [ "node", "." ]
|
||||
COPY docker.sh /docker.sh
|
||||
RUN chmod +x /docker.sh
|
||||
|
|
28
backend/Dockerfile-prod
Normal file
28
backend/Dockerfile-prod
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Check out https://hub.docker.com/_/node to select a new base image
|
||||
FROM node:16-slim
|
||||
|
||||
# Set to a non-root built-in user `node`
|
||||
USER node
|
||||
|
||||
# Create app directory (with user `node`)
|
||||
RUN mkdir -p /home/node/app
|
||||
|
||||
WORKDIR /home/node/app
|
||||
|
||||
# Install app dependencies
|
||||
# A wildcard is used to ensure both package.json AND package-lock.json are copied
|
||||
# where available (npm@5+)
|
||||
COPY --chown=node package*.json ./
|
||||
|
||||
RUN npm install
|
||||
|
||||
# Bundle app source code
|
||||
COPY --chown=node . .
|
||||
|
||||
RUN npm run build
|
||||
|
||||
# Bind to all network interfaces so that it can be mapped to the host OS
|
||||
ENV HOST=0.0.0.0
|
||||
|
||||
EXPOSE ${PORT}
|
||||
CMD [ "node", "." ]
|
11
backend/docker.sh
Normal file
11
backend/docker.sh
Normal file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [ "$COMMAND" == "deploy" ]; then
|
||||
echo TODO
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Installing packages"
|
||||
npm install
|
||||
echo "Running application"
|
||||
npm run start:watch
|
6827
backend/package-lock.json
generated
6827
backend/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -33,6 +33,7 @@
|
|||
"openapi-spec": "node ./dist/openapi-spec",
|
||||
"prestart": "npm run rebuild",
|
||||
"start": "node -r source-map-support/register .",
|
||||
"start:watch": "tsc-watch --target es2017 --outDir ./dist --onSuccess \"node .\"",
|
||||
"clean": "lb-clean dist *.tsbuildinfo .eslintcache",
|
||||
"rebuild": "npm run clean && npm run build"
|
||||
},
|
||||
|
@ -59,11 +60,12 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@loopback/build": "^7.0.2",
|
||||
"source-map-support": "^0.5.20",
|
||||
"@loopback/eslint-config": "^11.0.2",
|
||||
"@loopback/testlab": "^3.4.4",
|
||||
"@types/node": "^10.17.60",
|
||||
"@loopback/eslint-config": "^11.0.2",
|
||||
"eslint": "^7.32.0",
|
||||
"source-map-support": "^0.5.20",
|
||||
"tsc-watch": "^4.5.0",
|
||||
"typescript": "~4.4.4"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,10 @@ services:
|
|||
build: backend
|
||||
ports:
|
||||
- "8019:3000"
|
||||
volumes:
|
||||
- ./backend:/home/node/app
|
||||
environment:
|
||||
- COMMAND=run
|
||||
|
||||
networks:
|
||||
default:
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
FROM node:16
|
||||
|
||||
USER node
|
||||
|
||||
EXPOSE 4200
|
||||
|
||||
WORKDIR /home/node/app
|
||||
|
|
Loading…
Reference in a new issue