diff --git a/.dockerignore b/.dockerignore index 3f43985..4f50512 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,3 +7,5 @@ .dockerignore Dockerfile docker-compose.yaml +/node_modules/ +/npm-debug.log/ \ No newline at end of file diff --git a/Dockerfile.client b/Dockerfile.client index aa6c220..0fdd204 100644 --- a/Dockerfile.client +++ b/Dockerfile.client @@ -1,28 +1,20 @@ -FROM node:9.3.0-alpine +FROM node:8 -# install static server -RUN npm install -g serve +# Create app directory +WORKDIR /usr/src/app -# create a 'tmp' folder for the build and make it the current working directory -WORKDIR /app/tmp +# Install app dependencies +# A wildcard is used to ensure both package.json AND package-lock.json are copied +# where available (npm@5+) +COPY ./client/package*.json ./ -# copy only the package.json to take advantage of cached Docker layers -COPY package.json . - -# install project dependencies RUN npm install +# If you are building your code for production +# RUN npm install --only=production -# copy project files and folders to the working directory -COPY . . +# Bundle app source +COPY ./client . -# build for production with minification -RUN npm run build - -# make the 'app' folder the current working directory -WORKDIR /app - -# clean up (i.e. extract 'dist' folder and remove everything else) -RUN mv tmp/dist dist && rm -fr tmp - -EXPOSE 5000 -CMD [ "serve", "--single", "--port", "3000", "dist" ] \ No newline at end of file +EXPOSE 3000 +RUN npm run build:dev +CMD ["node", "dist/index.js"] \ No newline at end of file diff --git a/client/package.json b/client/package.json index a020f4f..fb5e604 100644 --- a/client/package.json +++ b/client/package.json @@ -5,7 +5,6 @@ "main": "dist/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "build:prod": "webpack --config webpack.config.prod.js", "build:dev": "webpack --config webpack.config.js", "dev": "tsc-watch src/index.ts --outDir ./dist --onSuccess 'node ./dist/index.js' --onFailure 'echo Beep! Compilation Failed'" }, diff --git a/docker-compose.yaml b/docker-compose.yaml index f8e5cc2..c316c9f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -43,6 +43,16 @@ services: ports: - '443:443' + client: + build: + context: . + dockerfile: ./Dockerfile.client + volumes: + # Comment out the next line in production + - ./client:/usr/src/app:rw + ports: + - 3000:3000 + # For development purposes adminer: image: adminer