diff --git a/client/Dockerfile b/client/Dockerfile new file mode 100644 index 0000000..939a4a3 --- /dev/null +++ b/client/Dockerfile @@ -0,0 +1,13 @@ +# build stage +FROM node:lts-alpine as build-stage +WORKDIR /app +COPY package*.json ./ +RUN npm install +COPY . . +RUN npm run build + +# production stage +FROM nginx:stable-alpine as production-stage +COPY --from=build-stage /app/public /usr/share/nginx/html +EXPOSE 80 +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/client/nginx.conf b/client/nginx.conf new file mode 100644 index 0000000..7025312 --- /dev/null +++ b/client/nginx.conf @@ -0,0 +1,46 @@ +server { + listen 80; + server_name localhost; + + #charset koi8-r; + #access_log /var/log/nginx/host.access.log main; + + root /usr/share/nginx/html; + index index.html; + + location / { + try_files $uri /index.html; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + # error_page 500 502 503 504 /50x.html; + # location = /50x.html { + # root /usr/share/nginx/html; + # } + + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 + # + #location ~ \.php$ { + # proxy_pass http://127.0.0.1; + #} + + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + # + #location ~ \.php$ { + # root html; + # fastcgi_pass 127.0.0.1:9000; + # fastcgi_index index.php; + # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; + # include fastcgi_params; + #} + + # deny access to .htaccess files, if Apache's document root + # concurs with nginx's one + # + #location ~ /\.ht { + # deny all; + #} +} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7db8365 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,54 @@ +version: '3' + +services: + client: + container_name: hve_client + restart: on-failure + build: + context: . + dockerfile: ./Dockerfile + volumes: + - ./client/nginx.conf:/etc/nginx/conf.d/default.conf:ro + environment: + - NODE_ENV=production + networks: + - default + - web + command: ['nginx', '-g', 'daemon off;'] + # labels: + # - 'traefik.docker.network=web' + # - 'traefik.enable=true' + # - 'traefik.domain=hve.crvx.fr' + # - 'traefik.basic.frontend.rule=Host:hve.crvx.fr' + # - 'traefik.basic.port=80' + # - 'traefik.basic.protocol=http' + # - 'traefik.frontend.headers.SSLRedirect=true' + # - 'traefik.frontend.headers.STSSeconds=315360000' + # - 'traefik.frontend.headers.browserXSSFilter=true' + # - 'traefik.frontend.headers.contentTypeNosniff=true' + # - 'traefik.frontend.headers.forceSTSHeader=true' + # - "traefik.frontend.headers.contentSecurityPolicy=default-src 'self';frame-ancestors 'self';style-src 'self';script-src 'self';img-src 'self';font-src 'self'" + # - 'traefik.frontend.headers.referrerPolicy=no-referrer' + # - 'traefik.frontend.headers.frameDeny=true' + + api: + container_name: hve_api + restart: on-failure + image: node:8 + build: + context: . + dockerfile: ./server/Dockerfile + env_file: + - .env + environment: + - NODE_ENV=production + ports: + - '3000:3000' + networks: + - default + - postgres + command: ['node', '/api/server/index.js'] + +networks: + web: + external: true diff --git a/server/Dockerfile b/server/Dockerfile new file mode 100644 index 0000000..76dd737 --- /dev/null +++ b/server/Dockerfile @@ -0,0 +1,12 @@ +FROM node:8 + +WORKDIR /api + +COPY ./package-lock.json . +COPY ./package.json . +COPY ./server ./server + +# Build +RUN npm install --prefix /api + +EXPOSE 3000 \ No newline at end of file