Doc updates for Docker/devcontainers/codespace (#30582)

This commit is contained in:
Matt Jankowski 2024-06-07 16:18:02 -04:00 committed by GitHub
parent 496c10542b
commit 521b433933
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 38 additions and 26 deletions

View file

@ -1,20 +1,17 @@
# For details, see https://github.com/devcontainers/images/tree/main/src/ruby # For details, see https://github.com/devcontainers/images/tree/main/src/ruby
FROM mcr.microsoft.com/devcontainers/ruby:1-3.3-bookworm FROM mcr.microsoft.com/devcontainers/ruby:1-3.3-bookworm
# Install Rails # Update existing node version, keep in sync with .nvmrc
# RUN gem install rails webdrivers
ARG NODE_VERSION="20" ARG NODE_VERSION="20"
RUN . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1 RUN . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1
# [Optional] Uncomment this section to install additional OS packages. # Install additional OS packages
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ RUN apt-get update && \
&& apt-get -y install --no-install-recommends libicu-dev libidn11-dev ffmpeg imagemagick libvips42 libpam-dev export DEBIAN_FRONTEND=noninteractive && \
apt-get -y install --no-install-recommends libicu-dev libidn11-dev ffmpeg imagemagick libvips42 libpam-dev
# [Optional] Uncomment this line to install additional gems. # Install global node packages
RUN gem install foreman
# [Optional] Uncomment this line to install global node packages.
RUN . /usr/local/share/nvm/nvm.sh && corepack enable 2>&1 RUN . /usr/local/share/nvm/nvm.sh && corepack enable 2>&1
# Move welcome message to where VS Code expects it
COPY welcome-message.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt COPY welcome-message.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt

View file

@ -1,6 +1,6 @@
{ {
"name": "Mastodon on GitHub Codespaces", "name": "Mastodon on GitHub Codespaces",
"dockerComposeFile": "../docker-compose.yml", "dockerComposeFile": "../compose.yaml",
"service": "app", "service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",

View file

@ -1,6 +1,6 @@
{ {
"name": "Mastodon on local machine", "name": "Mastodon on local machine",
"dockerComposeFile": "docker-compose.yml", "dockerComposeFile": "compose.yaml",
"service": "app", "service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",

View file

@ -102,26 +102,35 @@ To set up **MacOS** for native development, complete the following steps:
### Docker ### Docker
For production hosting and deployment with **Docker**, use the `Dockerfile` and For production hosting and deployment with **Docker**, use the `Dockerfile` and
`docker-compose.yml` in the project root directory. To create a local `docker-compose.yml` in the project root directory.
development environment with **Docker**, complete the following steps:
- Install Docker Desktop For local development, install and launch [Docker], and run:
- Run `docker compose -f .devcontainer/docker-compose.yml up -d`
- Run `docker compose -f .devcontainer/docker-compose.yml exec app bin/setup`
- Finally, run `docker compose -f .devcontainer/docker-compose.yml exec app bin/dev`
If you are using an IDE with [support for the Development Container specification](https://containers.dev/supporting), it will run the above `docker compose` commands automatically. For **Visual Studio Code** this requires the [Dev Container extension](https://containers.dev/supporting#dev-containers). ```shell
docker compose -f .devcontainer/compose.yaml up -d
docker compose -f .devcontainer/compose.yaml exec app bin/setup
docker compose -f .devcontainer/compose.yaml exec app bin/dev
```
### Dev Containers
Within IDEs that support the [Development Containers] specification, start the
"Mastodon on local machine" container from the editor. The necessary `docker
compose` commands to build and setup the container should run automatically. For
**Visual Studio Code** this requires installing the [Dev Container extension].
### GitHub Codespaces ### GitHub Codespaces
To get you coding in just a few minutes, GitHub Codespaces provides a web-based version of Visual Studio Code and a cloud-hosted development environment fully configured with the software needed for this project.. [GitHub Codespaces] provides a web-based version of VS Code and a cloud hosted
development environment configured with the software needed for this project.
- Click this button to create a new codespace:<br> [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)][codespace]
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=52281283&devcontainer_path=.devcontainer%2Fcodespaces%2Fdevcontainer.json)
- Wait for the environment to build. This will take a few minutes. - Click the button to create a new codespace, and confirm the options
- When the editor is ready, run `bin/dev` in the terminal. - Wait for the environment to build (takes a few minutes)
- After a few seconds, a popup will appear with a button labeled _Open in Browser_. This will open Mastodon. - When the editor is ready, run `bin/dev` in the terminal
- On the _Ports_ tab, right click on the “stream” row and select _Port visibility__Public_. - Wait for an _Open in Browser_ prompt. This will open Mastodon
- On the _Ports_ tab "stream" setting change _Port visibility_ → _Public_
## Contributing ## Contributing
@ -140,3 +149,9 @@ This program is free software: you can redistribute it and/or modify it under th
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
[codespace]: https://codespaces.new/mastodon/mastodon?quickstart=1&devcontainer_path=.devcontainer%2Fcodespaces%2Fdevcontainer.json
[Dev Container extension]: https://containers.dev/supporting#dev-containers
[Development Containers]: https://containers.dev/supporting
[Docker]: https://docs.docker.com
[GitHub Codespaces]: https://docs.github.com/en/codespaces