refacto(Dockerfile): optimized with new setup
This commit is contained in:
parent
dcc5191a3c
commit
6c5016003a
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@ -0,0 +1,2 @@
|
||||
**/node_modules
|
||||
**/git
|
35
Dockerfile
35
Dockerfile
@ -1,4 +1,26 @@
|
||||
FROM node:11
|
||||
FROM node:11 as base
|
||||
|
||||
# Create app directory
|
||||
RUN mkdir -p /opt/app
|
||||
WORKDIR /opt/app
|
||||
|
||||
# Install app dependencies
|
||||
COPY ./package.json package-lock.json ./
|
||||
RUN npm ci
|
||||
|
||||
# Bundle frontend
|
||||
COPY src ./src
|
||||
COPY assets ./assets
|
||||
COPY config ./config
|
||||
RUN npm run build
|
||||
|
||||
|
||||
#####################
|
||||
# Final image
|
||||
#####################
|
||||
|
||||
FROM node:11-alpine
|
||||
ENV NODE_ENV=prod
|
||||
|
||||
MAINTAINER cracker0dks
|
||||
|
||||
@ -6,12 +28,11 @@ MAINTAINER cracker0dks
|
||||
RUN mkdir -p /opt/app
|
||||
WORKDIR /opt/app
|
||||
|
||||
# Install app dependencies
|
||||
COPY ./package.json /opt/app
|
||||
RUN npm install
|
||||
COPY ./package.json ./package-lock.json ./
|
||||
RUN npm ci --only=prod
|
||||
|
||||
# Bundle app source
|
||||
COPY . /opt/app
|
||||
COPY scripts ./scripts
|
||||
COPY --from=base /opt/app/public ./public
|
||||
|
||||
EXPOSE 8080
|
||||
CMD [ "npm", "start" ]
|
||||
ENTRYPOINT [ "npm", "run", "start:prod-no-build" ]
|
||||
|
@ -1,7 +1,3 @@
|
||||
const webpack = require("webpack");
|
||||
const WebpackDevServer = require("webpack-dev-server");
|
||||
const config = require("../config/webpack.dev");
|
||||
|
||||
const devServerConfig = {
|
||||
hot: true,
|
||||
inline: true,
|
||||
@ -19,6 +15,11 @@ const devServerConfig = {
|
||||
}
|
||||
|
||||
function startFrontendDevServer(port) {
|
||||
// require here to prevent prod dependency to webpack
|
||||
const webpack = require("webpack");
|
||||
const WebpackDevServer = require("webpack-dev-server");
|
||||
const config = require("../config/webpack.dev");
|
||||
|
||||
new WebpackDevServer(webpack(config), devServerConfig)
|
||||
.listen(port, (err) => {
|
||||
if (err) {
|
||||
|
Loading…
Reference in New Issue
Block a user