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

Simplify docker development environment #458

Merged
merged 1 commit into from
Apr 4, 2020

Conversation

sbocinec
Copy link
Contributor

This PR simplifies and fixes the docker development workflow.

CHANGES

BREAKING CHANGES - devs using docker for development might have slitghtly changed workflow as this PR:

  • Remove Dockerfile
  • Modify docker-compose.yml

Details

The original Dockerfile I created appeared to be redundant and not needed, as it doesn't bring any benefits:

  • node modules were installed into the node_modules during the docker image build, what is not needed and rather bad practice as during the development we are reinstalling the modules often = wasted space
  • we can simply use the vanilla node docker image without building our own image.

Copy link
Member

@fossecode fossecode left a comment

Choose a reason for hiding this comment

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

Looks good to me! Does any of you know about any others that use docker in prod that needs to be notified?

@michaelmcmillan
Copy link
Member

michaelmcmillan commented Mar 29, 2020

Nice! I've made some changes to the Dockerfile myself, I guess they're pretty much the same:

FROM node:lts-buster-slim

RUN mkdir /app

COPY package.json yarn.lock
COPY . .

WORKDIR /app
RUN yarn
CMD yarn start

Can you tag images using compose? I've been toying around with a k8s cluster – would need to be able to tag builds to keep it under control :)

@sbocinec
Copy link
Contributor Author

sbocinec commented Apr 2, 2020

Can you tag images using compose? I've been toying around with a k8s cluster – would need to be able to tag builds to keep it under control :)

@michaelmcmillan - in the development docker compose I'm suggesting here, there is actually no build step, it only mounts the application directory inside and run the yarn dev command. So as there is no build step, there is no new image produced = no tagging possible. This makes it super simple for the development on your own machine on top of the constantly chaning files in the app directory, but definitely not suitable for production as there the image has to be built with the app source code and the node_modules inside the image, exactly as you are doing.

And yeah, using your Dockerfile, docker compose can tag images on build, eg.:

...
services:
  app:
    build: .
    image: coronastatus:${VERSION:-latest}
...

And then running docker-compose build will also tag the image with the $VERSION or latest tag

@sbocinec
Copy link
Contributor Author

sbocinec commented Apr 2, 2020

Looks good to me! Does any of you know about any others that use docker in prod that needs to be notified?

@fossecode nope, I'm not aware of anyone else who is running it in docker in production.

As these changes are aimed to ease development, I think it's safe to LGTM :-)

@michaelmcmillan
Copy link
Member

Aha, now I see how it works. Didn't know that was possible!

LGTM 👍

@fossecode fossecode merged commit 3cd4b30 into BustByte:master Apr 4, 2020
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.

None yet

3 participants