-
Notifications
You must be signed in to change notification settings - Fork 4
Dockerizing Dev Setup #175
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| .git | ||
| *Dockerfile* | ||
| *docker-compose* | ||
| node_modules | ||
| .env* | ||
| .github | ||
| .husky |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| GITHUB_TOKEN=<create-your-own-token> | ||
| GITHUB_REPOSITORY=sushie1984/pr-update-extended | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| FROM alpine:3.16.2 AS base | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any reason not to use the official Node image in alpine flavour? |
||
|
|
||
| RUN apk add --no-cache npm git openssh | ||
|
|
||
| WORKDIR /home/node/ | ||
|
|
||
| COPY package.json package-lock-json* ./ | ||
|
Comment on lines
+5
to
+7
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a benefit in first setting the work dir instead of directly copying in the file to the required location? |
||
|
|
||
| RUN npm install --omit=optional && npm cache clean --force | ||
|
|
||
| ENV PATH /home/node/node_modules/.bin:$PATH | ||
|
|
||
| WORKDIR /home/node/app | ||
|
|
||
| COPY . . | ||
|
|
||
| RUN git config --global --add safe.directory /home/node/app | ||
|
|
||
| ENTRYPOINT ["npm"] | ||
|
|
||
| FROM base AS dev | ||
|
|
||
| RUN npm install -g typescript ts-node | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| .PHONY: copy_env | ||
| copy_env: | ||
| @cp -n .env.template .env.development | ||
| @cp -n .env.template .env.test | ||
|
|
||
| .PHONY: build | ||
| build: | ||
| docker-compose run --rm node run build | ||
|
|
||
| .PHONY: package | ||
| package: | ||
| @docker-compose run --rm dev run package | ||
|
|
||
| .PHONY: terminal | ||
| terminal: | ||
| @docker-compose run --rm --entrypoint /bin/ash dev | ||
|
|
||
| .PHONY: console | ||
| console: | ||
| @docker-compose run --rm --entrypoint /bin/ash dev -c "npx ts-node" | ||
|
|
||
| .PHONY: test | ||
| test: | ||
| @docker-compose run --rm test | ||
|
|
||
| .PHONY: lint | ||
| lint: | ||
| @docker-compose run --rm test run lint | ||
|
|
||
| .PHONY: format | ||
| format: | ||
| @docker-compose run --rm test run format | ||
|
|
||
| .PHONY: clean | ||
| clean: | ||
| @docker-compose down | ||
| @docker image prune -f | ||
| @docker images -a | grep "pr-update" | awk '{print $3}' | xargs docker rmi |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| version: "3.8" | ||
| services: | ||
| dev: | ||
| env_file: | ||
| - .env.development | ||
| environment: | ||
| - SSH_AUTH_SOCK=${SSH_AUTH_SOCK} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you elaborate what this does? (not familiar with this EnvVar) |
||
| build: | ||
| context: . | ||
| target: dev | ||
| stdin_open: true | ||
| tty: true | ||
| volumes: | ||
| - ./:/home/node/app | ||
| - ${SSH_AUTH_SOCK}:${SSH_AUTH_SOCK} | ||
| # Prevents unwanted mounting of node_modules from HOST into docker container. | ||
| - notused:/home/node/app/node_modules | ||
|
|
||
| test: | ||
| env_file: | ||
| - .env.test | ||
| environment: | ||
| - SSH_AUTH_SOCK=${SSH_AUTH_SOCK} | ||
| build: | ||
| context: . | ||
| target: base | ||
| command: run test | ||
| volumes: | ||
| - ./:/home/node/app | ||
| - ${SSH_AUTH_SOCK}:${SSH_AUTH_SOCK} | ||
| # Prevents unwanted mounting of node_modules from HOST into docker container. | ||
| - notused:/home/node/app/node_modules | ||
|
|
||
| volumes: | ||
| notused: | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just making a note here so we don't forget about it