Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Basic Docker Setup #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.git
.gitignore
.editorconfig
node_modules
*.log
*.md
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.idea/
node_modules/
node_modules
dist/
*.log
*.map
Expand Down
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
web:
build: .
command: npm run dev
ports:
- 80:8000
- 8080:8080
volumes:
- .:/app
17 changes: 17 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
Copy link

@ghost ghost Jul 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it needs a -d for checking the presence of the directory instead of -h for the shell inside of the container.

docker-compose up with-h fails for me the second time with:

$ docker-compose up
Starting irisfrontend_web_1
Attaching to irisfrontend_web_1
web_1  | Symlink preinstalled node_modules from /tmp
web_1  | ln: failed to create symbolic link '/app/node_modules/node_modules': File exists
irisfrontend_web_1 exited with code 1

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind—I forgot to delete the local node_modules, therefor it failed. Works.

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 "$@"