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
|
MAINTAINER cracker0dks
|
||||||
|
|
||||||
@ -6,12 +28,11 @@ MAINTAINER cracker0dks
|
|||||||
RUN mkdir -p /opt/app
|
RUN mkdir -p /opt/app
|
||||||
WORKDIR /opt/app
|
WORKDIR /opt/app
|
||||||
|
|
||||||
# Install app dependencies
|
COPY ./package.json ./package-lock.json ./
|
||||||
COPY ./package.json /opt/app
|
RUN npm ci --only=prod
|
||||||
RUN npm install
|
|
||||||
|
|
||||||
# Bundle app source
|
COPY scripts ./scripts
|
||||||
COPY . /opt/app
|
COPY --from=base /opt/app/public ./public
|
||||||
|
|
||||||
EXPOSE 8080
|
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 = {
|
const devServerConfig = {
|
||||||
hot: true,
|
hot: true,
|
||||||
inline: true,
|
inline: true,
|
||||||
@ -19,6 +15,11 @@ const devServerConfig = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function startFrontendDevServer(port) {
|
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)
|
new WebpackDevServer(webpack(config), devServerConfig)
|
||||||
.listen(port, (err) => {
|
.listen(port, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
Loading…
Reference in New Issue
Block a user