Update Docker guide in preparation for 2.3.0 (#561)

This commit is contained in:
Eugen Rochko 2018-03-09 11:56:08 +01:00 committed by GitHub
parent ee818ed99e
commit ceaa847cbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 36 deletions

View File

@ -1,6 +1,6 @@
## Docker ## Docker
[![](https://images.microbadger.com/badges/version/gargron/mastodon.svg)](https://microbadger.com/images/gargron/mastodon "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/image/gargron/mastodon.svg)](https://microbadger.com/images/gargron/mastodon "Get your own image badge on microbadger.com") [![](https://images.microbadger.com/badges/version/tootsuite/mastodon.svg)](https://microbadger.com/images/tootsuite/mastodon "Get your own version badge on microbadger.com") [![](https://images.microbadger.com/badges/image/tootsuite/mastodon.svg)](https://microbadger.com/images/tootsuite/mastodon "Get your own image badge on microbadger.com")
The project now includes a `Dockerfile` and a `docker-compose.yml` file (which requires at least docker-compose version `1.10.0`). The project now includes a `Dockerfile` and a `docker-compose.yml` file (which requires at least docker-compose version `1.10.0`).
@ -19,15 +19,6 @@ Clone Mastodon's repository.
Review the settings in `docker-compose.yml`. Note that it is **not default** to store the postgresql database and redis databases in a persistent storage location. If you plan on running your instance in production, you **must** uncomment the [`volumes` directive](https://github.com/tootsuite/mastodon/blob/972f6bc861affd9bc40181492833108f905a04b6/docker-compose.yml#L7-L16) in `docker-compose.yml`. Review the settings in `docker-compose.yml`. Note that it is **not default** to store the postgresql database and redis databases in a persistent storage location. If you plan on running your instance in production, you **must** uncomment the [`volumes` directive](https://github.com/tootsuite/mastodon/blob/972f6bc861affd9bc40181492833108f905a04b6/docker-compose.yml#L7-L16) in `docker-compose.yml`.
Then, you need to fill in the `.env.production` file:
cp .env.production.sample .env.production
nano .env.production
Do NOT change the `REDIS_*` or `DB_*` settings when running with the default docker configurations.
You will need to fill in, at least: `LOCAL_DOMAIN`, `LOCAL_HTTPS`, and the `SMTP_*` settings.
## Getting the Mastodon image ## Getting the Mastodon image
### Using a prebuilt image ### Using a prebuilt image
@ -38,7 +29,7 @@ To use the prebuilt images:
1. Open `docker-compose.yml` in your favorite text editor. 1. Open `docker-compose.yml` in your favorite text editor.
2. Comment out the `build: .` lines for all images (web, streaming, sidekiq). 2. Comment out the `build: .` lines for all images (web, streaming, sidekiq).
3. Edit the `image: gargron/mastodon` lines for all images to include the release you want. The default is `latest` which may not be a tagged release. If you wanted to use v2.2.0 for example, you would edit the lines to say: `image: gargron/mastodon:v2.2.0` 3. Edit the `image: tootsuite/mastodon` lines for all images to include the release you want. The default is `latest` which is the most recent stable version, however it recommended to explicitly pin a version: If you wanted to use v2.2.0 for example, you would edit the lines to say: `image: tootsuite/mastodon:v2.3.0`
4. Save the file and exit the text editor. 4. Save the file and exit the text editor.
4. Run `docker-compose build`. It will now pull the correct image from Docker Hub. 4. Run `docker-compose build`. It will now pull the correct image from Docker Hub.
@ -53,38 +44,19 @@ You must build your own image if you've made any code modifications. To build yo
## Building the app ## Building the app
Now the image can be used to generate secrets. Run the command below for each of `PAPERCLIP_SECRET`, `SECRET_KEY_BASE`, and `OTP_SECRET` then copy the results into the `.env.production` file: Now the image can be used to generate a configuration with:
docker-compose run --rm web rake secret docker-compose run --rm web rake mastodon:setup
To enable Web Push notifications, you should generate a private/public key pair and put them into your `.env.production` file. Run the command below to create `VAPID_PRIVATE_KEY` and `VAPID_PUBLIC_KEY` then copy the result into the `.env.production` file: This is an interactive wizard that will guide you through the basic and necessary options and generate new app secrets. At some point it will output your configuration, copy and paste that configuration into the `.env.production` file.
docker-compose run --rm web rake mastodon:webpush:generate_vapid_key The wizard will setup the database schema and precompile assets. After it's done, you can launch Mastodon with:
Then you should run the `db:setup` command to create the database:
docker-compose run --rm web rake db:setup
Then, you will also need to precompile the assets:
docker-compose run --rm web rake assets:precompile
before you can launch the docker image with:
docker-compose up
If you wish to run this as a daemon process instead of monitoring it on console, use instead:
docker-compose up -d docker-compose up -d
## Configuration ## Configuration
Then you may login to your new Mastodon instance by browsing to http://localhost:3000/ Following that, make sure that you read the [production guide](Production-guide.md), beginning with the section that describes how to point Nginx to Mastodon.
If you set `LOCAL_HTTPS` to true before, you have to prepare your TLS nginx first [production guide](Production-guide.md) because connecting to port 3000 redirects you to HTTPS.
Following that, make sure that you read the [production guide](Production-guide.md). You are probably going to want to understand how
to configure Nginx to make your Mastodon instance available to the rest of the world.
The container has two volumes, for the assets and for user uploads, and optionally two more, for the postgresql and redis databases. The container has two volumes, for the assets and for user uploads, and optionally two more, for the postgresql and redis databases.
@ -108,7 +80,7 @@ This approach makes updating to the latest version a real breeze.
3. `git checkout TAG_NAME` to use the tag code. (If you have committed changes, use `git merge TAG_NAME` instead, though this isn't likely.) 3. `git checkout TAG_NAME` to use the tag code. (If you have committed changes, use `git merge TAG_NAME` instead, though this isn't likely.)
4. Only if you ran `git stash`, now run `git stash pop` to redo your changes to `docker-compose.yml`. Double check the contents of this file. 4. Only if you ran `git stash`, now run `git stash pop` to redo your changes to `docker-compose.yml`. Double check the contents of this file.
5. Build the updated Mastodon image. 5. Build the updated Mastodon image.
- If you are using a prebuilt image: First, edit the `image: gargron/mastodon` lines in `docker-compose.yml` to include the tag for the new version. E.g. `image: gargron/mastodon:v2.2.0` - If you are using a prebuilt image: First, edit the `image: tootsuite/mastodon` lines in `docker-compose.yml` to include the tag for the new version. E.g. `image: tootsuite/mastodon:v2.3.0`
- To pull the prebuilt image, or build your own from the updated code: `docker-compose build` - To pull the prebuilt image, or build your own from the updated code: `docker-compose build`
6. (optional) `docker-compose run --rm web rake db:migrate` to perform database migrations. Does nothing if your database is up to date. 6. (optional) `docker-compose run --rm web rake db:migrate` to perform database migrations. Does nothing if your database is up to date.
7. (optional) `docker-compose run --rm web rake assets:precompile` to compile new JS and CSS assets. 7. (optional) `docker-compose run --rm web rake assets:precompile` to compile new JS and CSS assets.