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

Development Works out of the Box #16747

Open
Austio opened this issue Sep 17, 2021 · 10 comments
Open

Development Works out of the Box #16747

Austio opened this issue Sep 17, 2021 · 10 comments

Comments

@Austio
Copy link

Austio commented Sep 17, 2021

Pitch

Hey Team,

The current docker/docker-compose.yml explicitly targets production and the current steps for setting up a dev environment are a work in progress on the "getting started".

You can search in the issues and see quite a few issues with development, this would reduce the "help footprint" by providing an env for people to dev in, there are dozens, just picked a few

https://github.com/mastodon/mastodon/issues?q=is%3Aissue+development

I can setup a docker-compose.dev.yml and Docker.dev to support the env right now.

I think even better would be to invert this. It would break anything that currently depends on the docker being production

  • Make Dockerfile and docker-compose.yml target the development build
  • Create a new Dockerfile.prod and docker-compose.prod.yml

Alternatively

  • make docker-compose.yml target development, create a Dockerfile.dev
  • keep Dockerfile the same to reduce change of things breaking

Motivation

To support all the features, this is a relatively complex software system. Someone who hasn't worked on elastic,redis, rails and postgres for years is going to have a pretty rough time. whereas if we have a docker-compose.yml they can at least

docker-compose -f docker-compose.dev.yml up and be off to the races

@mumot1999
Copy link

Is it possible to sync files with dev container via docker-sync?
I would like to make changes in code on host and it should trigger recompile rails on container.

@CEbbinghaus
Copy link

I also opened #20466 which you might want to include in your list. I think having a easy to set up development environment is going to be important especially to increase community contributions to this absolutely amazing project.

@claudioc
Copy link

@Austio it would be awesome indeed to have a docker-compose setup to run a "light" development instance. I am working on a MacBookPro M1 and unfortunately, the Vagrant option doesn't really work (VirtualBox is not ready yet). The other option is indeed to use the docker-compose, but although I almost made it run, now I am stuck because apparently only HTTPS is supported but I am not going to install a reverse proxy just for that...

Also, by default localhost is a forbidden hostname and must be allowed in Rails' config.hosts.

@dkwgit
Copy link

dkwgit commented Nov 20, 2022

Just want to say that I think this could be such a super important issue to tackle, with the mass interest in Mastodon. I am finding it unusually challenging to get a development environment up and running. I am new to Mastodon, so some of this is about what I don't know, but I am finding this to be more challenging (to get a dev environment) than almost any other project I have a taken a look at. I can do it in WSL alone, but when I want to try to get the docker compose/dev container based approach going, it is incredibly difficult, imo. I am particularly interested in the Docker route, because I have a sense that down that path lies a more scalable option for people who want to run a server. My goal would be to get something that can run under AWS ECS (or equivalent) so that somebody running an instance can dynamically scale any part that needs scaling. I think that could be a sweet spot for people trying to host an instance--not a server per se, but something containerized that can expand and contract, but without the full administrative/learning/security overhead of K8S--which, I think is not worth setting up/paying for for one instance.

@claudioc
Copy link

In case someone is interested, I wrote a guide to run a dev environment in a MacBookPro M1 (pro / max) https://gist.github.com/claudioc/5b245d15677f27db36d07fc089ad0945

@amydevs
Copy link

amydevs commented Nov 21, 2022

I would really love this because setting up vagrant especially on a Linux host requires installing the Virtualbox kernel modules.

@nileshtrivedi
Copy link

I have raised PR #22206 that adds Dockerfile.dev and docker-compose.dev.yml files for this. The PR also has instructions on how to configure your .env.development, how to run Rails database migrations, create an admin user and start the app for local development.

@nileshtrivedi
Copy link

nileshtrivedi commented Dec 11, 2022

I closed my PR because as it turns out, Docker-based development workflow for Mastodon is already setup via VS Code's DevContainers.

The workflow is:

  • Open the mastodon repo folder in VS Code
  • Choose "Open Folder in Container"
  • Once in container, start a terminal and run foreman start
  • VS Code will prompt you that port 3000 has been exposed and offer to open this in the browser.

The correspondong Dockerfile and docker-compose.yml files are in .devcontainer folder.

@CEbbinghaus
Copy link

I closed my PR because as it turns out, Docker-based development workflow for Mastodon is already setup via VS Code's DevContainers.

Well this is what I tried but it errored and I haven't been able to figure it out by googling since it seems to be an extremely rare/isolated problem #20466

@nileshtrivedi
Copy link

@CEbbinghaus I don't have a Windows machine. But if you want to unblock yourself for now, you can take the Dockerfile.dev and docker-compose.dev.yml from my PR and run the commands in the PR description. Ping me at https://fosstodon.org/@nilesh in case you run into issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants