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

Add an init script #6

Open
michaelbaudino opened this issue Apr 18, 2019 · 8 comments
Open

Add an init script #6

michaelbaudino opened this issue Apr 18, 2019 · 8 comments
Assignees

Comments

@michaelbaudino
Copy link
Member

michaelbaudino commented Apr 18, 2019

It would be nice to have a simple script that creates a default docker-compose.yml in a project.

It should be callable pretty much like that:

docker run alpinelab/ruby-dev init

It could even take some arguments (--with-postgres=12-alpine, --new-rails-app, --new-gem, --with-webpacker).

@michaelbaudino michaelbaudino self-assigned this Apr 18, 2019
@michaelbaudino
Copy link
Member Author

Another useful command would be --port=9999 to choose the port. Setting this option would:

  • use ports: ["9999:9999"] in app service
  • set PORT=9999 in app/environment

@michaelbaudino
Copy link
Member Author

Add an empty docker-compose.override.yml:

version: "3"
services:
  app:
    environment:

@michaelbaudino
Copy link
Member Author

Another useful option would be --vscode-remote-config that would add a .devcontainer directory with the following files:

  • a .devcontainer/docker-compose.yml file:

    version: "3.1"
    services:
      app:
        command: /bin/sh -c "while sleep 1000; do :; done"
  • .devcontainer/devcontainer.json:

    {
      "name": "Existing Docker Compose (Extend)",
      "dockerComposeFile": [
        "../docker-compose.yml",
        "../docker-compose.override.yml",
        "docker-compose.yml"
      ],
      "service": "app",
      "workspaceFolder": "/app",
      "settings": {
        "terminal.integrated.shell.linux": null,
        "ruby.useBundler": true,
        "ruby.useLanguageServer": true,
        "ruby.lint": {
          "rubocop": {
            "useBundler": true
          }
        },
        "ruby.format": "rubocop"
      },
      "extensions": [
        "rebornix.ruby"
      ],
      "remoteUser": "user"
    }
    

    ℹ️ the extensions array could even be completed by extensions passed as argument: --vscode-remote-config=aliariff.slim-lint,attilabuti.vscode-mjml

@michaelbaudino
Copy link
Member Author

Another useful option would be --compose-file-format=3.5 to define the version key of docker-compose.yml and docker-compose.override.yml (and eventually .devcontainer/docker-compose.yml), they must all match.

@michaelbaudino
Copy link
Member Author

michaelbaudino commented Oct 13, 2020

Another useful option would be --procfile that would add:

  • a Procfile file (if it does not already exist), containing web: bin/rails server --b 0.0.0.0
  • a Procfile.dev file (which is a copy of existing or default Procfile)
  • a .foreman file, which contains procfile: Procfile.dev

@michaelbaudino
Copy link
Member Author

Another useful option would be --ruby=2.7.2 to define the Ruby version used (it will change the image field in docker-compose.yml to e.g. image: alpinelab/ruby-dev:2.7.2).

@michaelbaudino
Copy link
Member Author

Another useful option would be to autodetect some options, for example:

  • Ruby version from existing Gemfile, Gemfile.lock or .ruby-version
  • PostgreSQL presence from config/database.yml
  • Webpacker presence from Gemfile or Gemfile.lock

@michaelbaudino
Copy link
Member Author

Another useful idea would be a Rails template, that could be called like:

rails new my_new_app --template "https://github.com/alpinelab/docker-ruby-dev/blob/master/template.rb"

And it would add everything required by the new Rails app to use this image (a docker-compose.yml with autodetected features like Ruby version, PostgreSQL usage, …).

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

No branches or pull requests

1 participant