Improve setup with top level package.json

that can install or run client and server with a single command
This commit is contained in:
Stefan Forstenlechner 2022-06-02 20:58:30 +02:00
parent 2ecdb07d65
commit f9df91cbc8
3 changed files with 20 additions and 3 deletions

View File

@ -10,7 +10,7 @@ RUN mkdir built && \
mv build built && \ mv build built && \
mv package.minimize.docker.json built/package.json && \ mv package.minimize.docker.json built/package.json && \
cp package-lock.json built && \ cp package-lock.json built && \
npm --prefix built/ ci --only=production npm ci --prefix ./built --only=production
FROM node:16.14.2-alpine as server-builder FROM node:16.14.2-alpine as server-builder
@ -33,4 +33,4 @@ EXPOSE 3001
USER node USER node
WORKDIR /usr/src/app/picture-gallery-server WORKDIR /usr/src/app/picture-gallery-server
CMD npm --prefix ../picture-gallery-client/ run set-environment && node dist/app.js CMD npm run --prefix ../picture-gallery-client/ set-environment && node dist/app.js

View File

@ -27,5 +27,5 @@ REACT_APP_FAVICON_HREF=<URL to your favicon>
And run docker with `--env-file .env` And run docker with `--env-file .env`
```shell ```shell
docker run -p 3005:3001 -v //c/DATA/temp/bla:/usr/src/app/public --env-file .env --name my-picture-gallery simple-picture-gallery docker run -p 3005:3001 -v C:/DATA/temp/bla:/usr/src/app/public --env-file .env --name my-picture-gallery simple-picture-gallery
``` ```

17
package.json Normal file
View File

@ -0,0 +1,17 @@
{
"name": "simple-picture-gallery",
"version": "1.0.0",
"dependencies": {
"concurrently": "7.2.1"
},
"scripts": {
"install-all": "npm i && concurrently npm:install:client npm:install:server",
"install:client": "cd picture-gallery-client && npm i",
"install:server": "cd picture-gallery-server && npm i",
"start-all": "npm run build:client && concurrently npm:start:client npm:run:server",
"build:client": "npm run --prefix picture-gallery-client build-client",
"start:client": "npm run --prefix picture-gallery-client start-client",
"run:server": "npm run --prefix picture-gallery-server run-server",
"docker:buildImage": "docker build . -t simple-picture-gallery"
}
}