Don't rely on --net=host

This commit is contained in:
James Allen 2015-02-09 16:18:58 +00:00
parent c15caa4698
commit 531f9e84ac
3 changed files with 114 additions and 23 deletions

View file

@ -59,10 +59,6 @@ ADD runit/web-sharelatex.sh /etc/service/web-sharelatex/run
RUN mkdir /etc/sharelatex RUN mkdir /etc/sharelatex
ADD settings.coffee /etc/sharelatex/settings.coffee ADD settings.coffee /etc/sharelatex/settings.coffee
# phusion/baseimage init script
ADD 00_regen_sharelatex_secrets.sh /etc/my_init.d/00_regen_sharelatex_secrets.sh
ADD 00_make_sharelatex_data_dirs.sh /etc/my_init.d/00_make_sharelatex_data_dirs.sh
# TexLive # TexLive
RUN apt-get install -y wget RUN apt-get install -y wget
RUN wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz; \ RUN wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz; \
@ -71,6 +67,8 @@ RUN wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz; \
RUN echo "selected_scheme scheme-basic" >> /install-tl-unx/texlive.profile; \ RUN echo "selected_scheme scheme-basic" >> /install-tl-unx/texlive.profile; \
/install-tl-unx/install-tl -profile /install-tl-unx/texlive.profile /install-tl-unx/install-tl -profile /install-tl-unx/texlive.profile
RUN rm -r /install-tl-unx; \
rm install-tl-unx.tar.gz
ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/texlive/2014/bin/x86_64-linux/ ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/texlive/2014/bin/x86_64-linux/
RUN tlmgr install latexmk RUN tlmgr install latexmk
@ -78,4 +76,11 @@ RUN tlmgr install latexmk
# Aspell # Aspell
RUN apt-get install -y aspell aspell-en aspell-af aspell-am aspell-ar aspell-ar-large aspell-bg aspell-bn aspell-br aspell-ca aspell-cs aspell-cy aspell-da aspell-de aspell-de-alt aspell-el aspell-eo aspell-es aspell-et aspell-eu-es aspell-fa aspell-fo aspell-fr aspell-ga aspell-gl-minimos aspell-gu aspell-he aspell-hi aspell-hr aspell-hsb aspell-hu aspell-hy aspell-id aspell-is aspell-it aspell-kk aspell-kn aspell-ku aspell-lt aspell-lv aspell-ml aspell-mr aspell-nl aspell-no aspell-nr aspell-ns aspell-or aspell-pa aspell-pl aspell-pt-br aspell-ro aspell-ru aspell-sk aspell-sl aspell-ss aspell-st aspell-sv aspell-ta aspell-te aspell-tl aspell-tn aspell-ts aspell-uk aspell-uz aspell-xh aspell-zu RUN apt-get install -y aspell aspell-en aspell-af aspell-am aspell-ar aspell-ar-large aspell-bg aspell-bn aspell-br aspell-ca aspell-cs aspell-cy aspell-da aspell-de aspell-de-alt aspell-el aspell-eo aspell-es aspell-et aspell-eu-es aspell-fa aspell-fo aspell-fr aspell-ga aspell-gl-minimos aspell-gu aspell-he aspell-hi aspell-hr aspell-hsb aspell-hu aspell-hy aspell-id aspell-is aspell-it aspell-kk aspell-kn aspell-ku aspell-lt aspell-lv aspell-ml aspell-mr aspell-nl aspell-no aspell-nr aspell-ns aspell-or aspell-pa aspell-pl aspell-pt-br aspell-ro aspell-ru aspell-sk aspell-sl aspell-ss aspell-st aspell-sv aspell-ta aspell-te aspell-tl aspell-tn aspell-ts aspell-uk aspell-uz aspell-xh aspell-zu
# phusion/baseimage init script
ADD 00_regen_sharelatex_secrets.sh /etc/my_init.d/00_regen_sharelatex_secrets.sh
ADD 00_make_sharelatex_data_dirs.sh /etc/my_init.d/00_make_sharelatex_data_dirs.sh
ADD 00_set_docker_host_ipaddress.sh /etc/my_init.d/00_set_docker_host_ipaddress.sh
EXPOSE 80
ENTRYPOINT ["/sbin/my_init"] ENTRYPOINT ["/sbin/my_init"]

118
README.md
View file

@ -1,32 +1,105 @@
ShareLaTeX Docker Image ShareLaTeX Docker Image
======================= =======================
*THIS IS A WORK IN PROGRESS AND THESE INSTRUCTIONS DO NOT WORK YET!* **Please read this entire file before installing ShareLaTeX via Docker. It's only
short but contains some important information.**
The recommended way to install and run ShareLaTeX Community Edition is via Docker: The recommended way to install and run ShareLaTeX Community Edition is via Docker:
``` ```
$ docker run -d -v /sharelatex-data:/var/lib/sharelatex --net=host --name=sharelatex sharelatex/sharelatex $ docker run -d -v sharelatex:/var/lib/sharelatex --name=sharelatex sharelatex/sharelatex
``` ```
This will download the ShareLaTeX image and start it running in the background. This will download the ShareLaTeX image and start it running in the background.
**Which port does it listen on?**. To stop ShareLaTeX:
```
docker stop sharelatex
```
and to start it again:
```
docker start sharelatex
```
If you want to permanently remove ShareLaTeX from your docker containers:
```
docker rm sharelatex
```
### Storing Data
The `-v sharelatex:/var/lib/sharelatex` option in the `run` command tells
Docker to make the host directory `sharelatex` available inside the container for
ShareLaTeX to store data files in. This means that you can back up and access these
files manually outside of the ShareLaTeX container. If you would like to store ShareLaTeX data
in a different location, such as `/home/james/my_data`, just change this parameter:
```
$ docker run -d \
-v /home/james/my_data:/var/lib/sharelatex \
--name=sharelatex \
sharelatex/sharelatex
```
Do not change the second part of this parameter (after the :).
This is only where ShareLaTeX stores on-disk data.
Other data is also stored in Mongo and Redis.
### Mongo and Redis ### Mongo and Redis
The `--net=host` option to docker will allow the ShareLaTeX container to access ShareLaTeX depends on [MongoDB](http://www.mongodb.org/) (must be 2.4 or later), and
ports on the local system. By default it looks for an instance of [Redis](http://redis.io/) (must be version 2.6.12 or later).
[MongoDB](http://www.mongodb.org/) (must be version 2.4 or later) running on port 27017, and These should be running on the host system.
[Redis](http://redis.io/) (must be version 2.6.12 or later) running on port 6379. These are the default ports for
a standard installation of MongoDB and Redis.
### Persisting and backing up data By default the ShareLaTeX Docker container looks for these running on the host
machine at port 27017 (for Mongo) and port 6379 (for Redis). These are the defaults
ports for both databases so you shouldn't need to change them.
The `-v /sharelatex-data:/var/lib/sharelatex` option in the `run` command tells Docker to mount the local If you want to point ShareLaTeX at a database in a different location, you can
directory `/sharelatex-data` in the container at `/var/lib/sharelatex`. This is configure the container with environment variables. See the **Configuration Options**
where ShareLaTeX will store user uploaded files, and allows you to make external backups section below.
of these files, as well as persist them between updates to the ShareLaTeX image.
*Note that `localhost` in the container refers only to the container, so if you
want to access services on the host machine then you should use `dockerhost`.* For example:
```
$ docker run -d \
-v sharelatex:/var/lib/sharelatex \
--name=sharelatex \
--env SHARELATEX_MONGO_URL=mongodb://dockerhost/sharelatex \
sharelatex/sharelatex
```
### Backups
To backup the ShareLaTeX data, you need to backup the directory you have attached
to the container, as above. You also need to backup the Mongo and Redis databases.
### Running on a different port
The container listens on port 80 by default so you should be able to access
ShareLaTeX at http://localhost/. If you would like to run ShareLaTeX on a different
port (perhaps you have another service running on port 80, or want to put a proxy
in front of ShareLaTeX), then you can forward port 80 from the Docker container
to any other port with the `-p <PORT>:80` option. For example, to have ShareLaTeX
listen on port 5000:
```
$ docker run -d \
-v sharelatex:/var/lib/sharelatex \
--name=sharelatex \
-p 5000:80 \
--env SHARELATEX_SITE_URL=http://localhost:5000 \
sharelatex/sharelatex
```
(Note that you also have to update the `SHARELATEX_SITE_URL` parameter so that
it knows where it is publicly available.)
### LaTeX environment ### LaTeX environment
@ -38,7 +111,7 @@ $ docker exec sharelatex tlmgr install scheme-full
``` ```
Or you can install packages manually as you need by replacing `scheme-full` by Or you can install packages manually as you need by replacing `scheme-full` by
the package name the package name.
### Configuration Options ### Configuration Options
@ -63,8 +136,21 @@ configured correctly!
* `SHARELATEX_REDIS_PORT`: The port of the Redis instance to use * `SHARELATEX_REDIS_PORT`: The port of the Redis instance to use
* `SHARELATEX_REDIS_PASS`: The password to use when connecting to Redis (if applicable) * `SHARELATEX_REDIS_PASS`: The password to use when connecting to Redis (if applicable)
* `SHARELATEX_SECURE_COOKIE`: Set this to something non-zero to use a secure cookie. * `SHARELATEX_SECURE_COOKIE`: Set this to something non-zero to use a secure cookie.
This requires that your ShareLaTeX instance is running behind SSL. Only use this if your ShareLaTeX instance is running behind a reverse proxy with SSL configured.
### Upgrading from older versions ### Upgrading from older versions
*TODO: Just stop container, remove 'sharelatex' tag, and run with the new version.* *Please make sure to back up all Mongo, Redis and on-disk data before upgrading.*
Stop and remove the currently running ShareLaTeX container:
```
$ docker stop sharelatex
$ docker rm sharelatex
```
Start a new container with the updated version of ShareLaTeX (to upgrade to version 1.4.0 for example):
```
$ docker run -d -v sharelatex:/var/lib/sharelatex --name=sharelatex sharelatex/sharelatex:1.4.0
```

View file

@ -21,7 +21,7 @@ module.exports =
# #
# The following works out of the box with Mongo's default settings: # The following works out of the box with Mongo's default settings:
mongo: mongo:
url : process.env["SHARELATEX_MONGO_URL"] or 'mongodb://127.0.0.1/sharelatex' url : process.env["SHARELATEX_MONGO_URL"] or 'mongodb://dockerhost/sharelatex'
# Redis is used in ShareLaTeX for high volume queries, like real-time # Redis is used in ShareLaTeX for high volume queries, like real-time
# editing, and session management. # editing, and session management.
@ -29,7 +29,7 @@ module.exports =
# The following config will work with Redis's default settings: # The following config will work with Redis's default settings:
redis: redis:
web: redisConfig = web: redisConfig =
host: process.env["SHARELATEX_REDIS_HOST"] or "localhost" host: process.env["SHARELATEX_REDIS_HOST"] or "dockerhost"
port: process.env["SHARELATEX_REDIS_PORT"] or "6379" port: process.env["SHARELATEX_REDIS_PORT"] or "6379"
password: process.env["SHARELATEX_REDIS_PASS"] or "" password: process.env["SHARELATEX_REDIS_PASS"] or ""
fairy: redisConfig fairy: redisConfig
@ -92,7 +92,7 @@ module.exports =
# Where your instance of ShareLaTeX can be found publicly. This is used # Where your instance of ShareLaTeX can be found publicly. This is used
# when emails are sent out and in generated links: # when emails are sent out and in generated links:
siteUrl: siteUrl = process.env["SHARELATEX_SITE_URL"] or 'http://localhost:3000' siteUrl: siteUrl = process.env["SHARELATEX_SITE_URL"] or 'http://localhost'
# The websocket layer of ShareLaTeX runs as separate service. # The websocket layer of ShareLaTeX runs as separate service.
# When running locally or in development, you can point the client to this # When running locally or in development, you can point the client to this