diff --git a/.dockerignore b/.dockerignore index a51ea8a..4f0a173 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,3 @@ node_modules/ doc/ +npm-debug.log diff --git a/Dockerfile b/Dockerfile index c88afc6..649ea8c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,19 @@ -FROM nginx:stable-alpine +FROM node:8.2 -# Copy frontend files and make them accesible to nginx -RUN mkdir /www -COPY build /www -RUN chown nginx:nginx -R /www -RUN chmod -R 0755 /www +# Create app directory +RUN mkdir -p /usr/src/app +WORKDIR /usr/src/app -# Copy nginx configuration -COPY etc/nginx/villas.conf /etc/nginx/conf.d/default.conf +# Install app dependencies +COPY package.json /usr/src/app/ +RUN npm install + +VOLUME /usr/src/app/build + +# Bundle app source +COPY . /usr/src/app +RUN npm run build + +EXPOSE 80 + +CMD [ "npm", "start" ] diff --git a/docker-compose.yml b/docker-compose.yml index ff25a1a..7dbf6f3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,14 +8,23 @@ networks: villas: services: - # The VILLASweb frontend + # Build the frontend with node into a Docker volume + # This container does nothing useful beside providing an + # assets container to the nginx service frontend: build: context: . + command: "/bin/true" + + nginx: + image: nginx:stable-alpine ports: - "80:80" - "443:443" - restart: always + volumes: + - "./etc/nginx/villas.conf:/etc/nginx/conf.d/default.conf" + volumes_from: + - frontend networks: villas: diff --git a/etc/nginx/villas.conf b/etc/nginx/villas.conf index 4dabe64..a745f91 100644 --- a/etc/nginx/villas.conf +++ b/etc/nginx/villas.conf @@ -27,7 +27,7 @@ server { # frontend location location / { - root /www; + root /usr/src/app/build/; } # error pages