updates for docker

master
Tudor Stanciu 2020-04-14 17:51:31 +03:00
parent c18de01fdf
commit 9a67a13312
4 changed files with 52 additions and 5 deletions

View File

@ -4,13 +4,40 @@ WORKDIR /app
COPY package*.json ./
RUN npm install
#RUN printf '\nAm rulat npm install!\n\n'
#RUN echo '\nRezultat:\n'
#RUN ls
COPY . ./
RUN npm run build
#RUN printf '\nAm copiat restul fisierelor si am rulat build!\n\n'
#RUN echo '\nRezultat:\n'
#RUN ls
# production environment
FROM node:12
COPY --from=builder /app/build ./build
RUN npm install
#RUN printf '\nAm copiat fisierele din build in imaginea finala!\n\n'
#RUN echo '\nRezultat:\n'
#RUN ls
#RUN printf '\nM-am mutat in directorul build!\n\n'
#RUN echo '\nRezultat:\n'
#RUN ls
#install static server
RUN npm install -g serve
#RUN printf '\nAm rulat npm install in imaginea finala!\n\n'
#RUN echo '\nRezultat:\n'
#RUN ls
EXPOSE 80
CMD ["sh","-c","node serve -s build -p 80"]
#CMD ["npm", "run", "start:prod"]
# Comenzile urmatoare sunt similare:
#CMD ["sh", "-c", "serve -s build -p 80"]
CMD ["serve", "-s", "build", "-p", "80"]

19
Notes.txt Normal file
View File

@ -0,0 +1,19 @@
#############################
# Config initial scripts: #
#############################
"scripts": {
"start": "run-p start:dev start:api",
"start:dev": "webpack-dev-server --config webpack.config.dev.js --port 3000",
"prestart:api": "node tools/createMockDb.js",
"start:api": "node tools/apiServer.js",
"test": "jest --watch",
"test:ci": "jest",
"clean:build": "rimraf ./build && mkdir build",
"prebuild": "run-p clean:build test:ci",
"build": "webpack --config webpack.config.prod.js",
"postbuild": "run-p start:api serve:build",
"serve:build": "http-server ./build"
}
- "postbuild" este apelat automat dupa "build" si este util in cazul in care se doreste ca aplicatia sa porneasca automat dupa executia unui build
- in cazul in care se doreste doar executia unui build, se elimina "postbuild". Poate fi redenumit in "start:prod" si rulat ulterior astfel "npm run start:prod"

5
package-lock.json generated
View File

@ -1,7 +1,8 @@
{
"name": "ps-redux",
"requires": true,
"name": "react-redux-course",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@babel/code-frame": {
"version": "7.8.3",

View File

@ -13,7 +13,7 @@
"clean:build": "rimraf ./build && mkdir build",
"prebuild": "run-p clean:build test:ci",
"build": "webpack --config webpack.config.prod.js",
"postbuild": "run-p start:api serve:build",
"start:prod": "run-p start:api serve:build",
"serve:build": "http-server ./build"
},
"jest": {