diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..ebf60d8 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.git +.gitignore +.editorconfig +node_modules +*.log +*.md diff --git a/.gitignore b/.gitignore index 947dcde..e864a93 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ .idea/ -node_modules/ +node_modules dist/ *.log *.map diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4343e6f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM node:argon + +WORKDIR /tmp +ADD package.json /tmp/ +RUN npm install + +RUN mkdir /app +WORKDIR /app + +ENTRYPOINT ["sh", "docker-entrypoint.sh"] +CMD ["bash"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5ac2cf1 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +web: + build: . + command: npm run dev + ports: + - 80:8000 + - 8080:8080 + volumes: + - .:/app diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..5486bd9 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Exit immediately if a command exits with a non-zero status. +set -e + +# Symlink /tmp/node_modules if necessary +if [ ! -h 'node_modules' ]; then + echo "Symlink preinstalled node_modules from /tmp" + ln -s /tmp/node_modules /app/node_modules +fi + +# Add pre-commit git hook +echo "Add pre-commit git hook" +echo "#!/bin/sh\n\ndocker exec `hostname` `pwd`/node_modules/pre-commit/hook" > .git/hooks/pre-commit +chmod a+x .git/hooks/pre-commit + +exec "$@"