Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Containerized the app-backend 🐳🐳🐳 #87

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

tejas-hosamani
Copy link
Contributor

@tejas-hosamani tejas-hosamani commented Oct 5, 2019

A lot of things have happened.

Regarding...

yarn.lock:

  1. Cloned a fresh copy of app-backend repo (develop branch)
  2. Did yarn install
  3. Then yarn remove puppeteer jest-puppeteer

docs.test.js:

  1. Wrote docs tests using JEST-only to avoid Puppeteer all together.

other files:

  1. docker-compose manages multiple images.
  2. Makefile gives easy access to docker commands.
  3. Added a new entry to SETUP_TYPE=manual|docker to .env.sample file. This is being used inside preCommit.sh file while running pre-commit hook.
  4. Added .prettierignore file to keep Makefile format intact.
  5. docker-compose-test.yml is an optional file, which can be used to run tests inside new docker meant to run tests. However, I am using the same(dev) container for tests during the pre-commit hook.

How it all works:

  1. Both docker setup and regular setup are functional.
  2. For docker setup, the contributor needs to run make setup command inside the project directory.
  3. Once that's done, .env file needs to be edited(I will automate this) they can start the server with make start. This runs docker containers in the background and they can consume APIs at http://localhost (at default, port 80).
  4. Once that's done, they can write code and see modifications on the browser as usual.
  5. During the commit, pre-commit hook runs sh preCommit.sh, which checks whether the setup is manual or docker and based on that, it runs tests accordingly.
  6. Inside preCommit.sh file, I am not using && to run all commands in one line because I kept getting the error: stdin is not a tty. but spreading across multiple lines 'fixed' it.

Only downside to this whole setup is, users on windows with "regular" setup of this project, using GitBash cannot run git commit directly. but they would have to prepend winpty.
Example: winpty git commit -m "Commit message". This is a limitation with winpty and not the setup itself. but if they use Powershell, it works all OK. And docker setup works fine on both Gitbash and Powershell.

This setup needs to be rigorously tested, yet(I've done my best but..). On different machines. Please help me do that!!! As far as the setup itself, it's functional but few things can be modified and I'd love to have suggestions.

@tejas-hosamani tejas-hosamani marked this pull request as ready for review October 5, 2019 09:13
@tejas-hosamani
Copy link
Contributor Author

@spiray spiray mentioned this pull request Oct 7, 2019
@tejas-hosamani
Copy link
Contributor Author

For those who are going to review this, I've few obvious minor changes to make. I have this as a PR to have a review on the overall structure that I've built to make Docker work with regular, manual setup. Please keep that in mind while reviewing 🙂

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant