зеркало из https://github.com/mozilla/pontoon.git
Fix bug 1185698: Remove Docker environment.
Removes Docker-specific files and updates the documentation to remove references to Docker.
This commit is contained in:
Родитель
02e8afbe39
Коммит
9b22f5ba34
|
@ -24,3 +24,4 @@ tmp/*
|
|||
/static/
|
||||
.env
|
||||
docs/_build
|
||||
venv
|
||||
|
|
24
Dockerfile
24
Dockerfile
|
@ -1,24 +0,0 @@
|
|||
FROM python:2.7
|
||||
RUN apt-get update && apt-get install -y libjpeg62-turbo-dev postgresql-client nodejs npm vim
|
||||
|
||||
WORKDIR /pontoon
|
||||
|
||||
RUN npm install -g yuglify babel
|
||||
|
||||
# First copy requirements.txt and peep so we can take advantage of
|
||||
# docker caching.
|
||||
COPY requirements.txt /tmp/requirements.txt
|
||||
COPY ./bin/peep.py /tmp/peep.py
|
||||
|
||||
# Temporary fix: Downgrade pip since peep does not work with the latest
|
||||
# version.
|
||||
RUN pip install pip==6.1.1
|
||||
|
||||
RUN /tmp/peep.py install -r /tmp/requirements.txt
|
||||
|
||||
# Symlink node because Ubuntu's node binary is named nodejs.
|
||||
RUN ln -s /usr/bin/nodejs /usr/bin/node
|
||||
|
||||
EXPOSE 8000
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
ENV PYTHONDONTWRITEBYTECODE 1
|
|
@ -1,6 +0,0 @@
|
|||
#!/bin/bash
|
||||
# Build an instance of the site using docker-compose.
|
||||
set -e
|
||||
docker-compose build
|
||||
docker-compose run web ./bin/wait-for-db.sh ./bin/run-migrations.sh
|
||||
docker-compose run web ./bin/wait-for-db.sh ./manage.py update_projects
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/bash
|
||||
cd `dirname "$0"`/../docs
|
||||
make html
|
|
@ -1,2 +0,0 @@
|
|||
#!/bin/bash
|
||||
./manage.py runserver 0.0.0.0:8000
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/bash
|
||||
# Sync and migrate the database.
|
||||
./manage.py syncdb --noinput
|
||||
./manage.py migrate
|
|
@ -1,20 +0,0 @@
|
|||
#!/bin/bash
|
||||
# Wait for db container to be up and run a command.
|
||||
set +e
|
||||
|
||||
test_sql() {
|
||||
PGPASSWORD=asdf psql -h db -U pontoon -d pontoon -c ";" -q >/dev/null 2>&1
|
||||
}
|
||||
|
||||
tries=10
|
||||
while ! test_sql; do
|
||||
(( tries -= 1 ))
|
||||
if (( $tries <= 0 )); then
|
||||
echo "Could not connect to db container, aborting."
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Database is up, run the passed arguments as a command.
|
||||
$*
|
|
@ -1,29 +0,0 @@
|
|||
db:
|
||||
image: postgres:9.4
|
||||
environment:
|
||||
- POSTGRES_USER=pontoon
|
||||
- POSTGRES_PASSWORD=asdf
|
||||
web:
|
||||
build: .
|
||||
ports:
|
||||
- "8000:8000"
|
||||
volumes:
|
||||
- .:/pontoon
|
||||
- ~/.ssh:/root/.ssh:ro
|
||||
links:
|
||||
- db
|
||||
dns:
|
||||
- 8.8.8.8
|
||||
- 8.8.4.4
|
||||
environment:
|
||||
- PYTHONDONTWRITEBYTECODE=1
|
||||
- DOCKER=1
|
||||
- SECRET_KEY=asdf
|
||||
- DJANGO_DEV=True
|
||||
- DJANGO_DEBUG=True
|
||||
- DJANGO_LOG_LEVEL=DEBUG
|
||||
- DATABASE_URL=postgres://pontoon:asdf@db/pontoon
|
||||
- SESSION_COOKIE_SECURE=False
|
||||
- HMAC_KEY=asdf
|
||||
- STATIC_ROOT=/pontoon-static
|
||||
command: ./bin/run-compose.sh
|
|
@ -139,7 +139,7 @@ html_theme = 'sphinx_rtd_theme'
|
|||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
#html_static_path = ['_static']
|
||||
|
||||
# Add any extra paths that contain custom files (such as robots.txt or
|
||||
# .htaccess) here, relative to this directory. These files are copied
|
||||
|
|
|
@ -1,67 +1,128 @@
|
|||
Developer Setup
|
||||
===============
|
||||
1. `Install Docker and Compose`_.
|
||||
The following describes how to set up an instance of the site on your
|
||||
computer for development.
|
||||
|
||||
2. Clone this repository or your fork_:
|
||||
Prerequisites
|
||||
-------------
|
||||
This guide assumes you have already installed and set up the following:
|
||||
|
||||
1. Git_
|
||||
2. `Python 2.7`_, pip_, and virtualenv_
|
||||
3. `Node.js`_ and npm_
|
||||
4. `Postgres 9.4`_
|
||||
|
||||
These docs assume a Unix-like operating system, although the site should, in
|
||||
theory, run on Windows as well. All the example commands given below are
|
||||
intended to be run in a terminal.
|
||||
|
||||
.. _Git: https://git-scm.com/
|
||||
.. _Python 2.7: https://www.python.org/
|
||||
.. _pip: https://pip.pypa.io/en/stable/
|
||||
.. _virtualenv: https://virtualenv.pypa.io/en/latest/
|
||||
.. _Node.js: https://nodejs.org/
|
||||
.. _npm: https://www.npmjs.com/
|
||||
.. _Postgres 9.4: http://www.postgresql.org/
|
||||
|
||||
Installation
|
||||
------------
|
||||
1. Clone this repository or your fork_:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
git clone --recursive https://github.com/mozilla/pontoon.git
|
||||
cd pontoon
|
||||
|
||||
3. **Optional**: If you're running the site via boot2docker_, you'll want to add
|
||||
a ``.env`` file to the project's root director with the IP address of the
|
||||
boot2docker VM.
|
||||
2. Create a virtualenv for Pontoon and activate it:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
echo "SITE_URL=http://$(boot2docker ip):8000" > .env
|
||||
virtualenv venv
|
||||
source ./venv/bin/activate
|
||||
|
||||
4. Build the development instance using the build script:
|
||||
.. note::
|
||||
|
||||
Whenever you want to work on Pontoon in a new terminal you'll have to
|
||||
re-activate the virtualenv. Read the virtualenv_ documentation to learn
|
||||
more about how virtualenv works.
|
||||
|
||||
3. Install the dependencies using peep_, a wrapper around pip that is
|
||||
included with Pontoon:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
boot2docker up
|
||||
eval "$(boot2docker shellinit)"
|
||||
./bin/build-docker.sh
|
||||
./bin/peep.py install -r requirements.txt
|
||||
|
||||
4. Create a ``.env`` file at the root of the repository to configure the
|
||||
settings for your development instance. It should look something like this:
|
||||
|
||||
.. code-block:: ini
|
||||
|
||||
SECRET_KEY=insert_random_key
|
||||
DJANGO_DEV=True
|
||||
DJANGO_DEBUG=True
|
||||
DATABASE_URL=postgres://pontoon:asdf@localhost/pontoon
|
||||
SESSION_COOKIE_SECURE=False
|
||||
HMAC_KEY=insert_random_key
|
||||
SITE_URL=http://localhost:8000
|
||||
|
||||
Make sure to make the following modifications to the template above:
|
||||
|
||||
- ``SECRET_KEY`` and ``HMAC_KEY`` should be set to some random key you
|
||||
come up with, as they are used to secure the authentication data for
|
||||
your local instance.
|
||||
|
||||
- ``DATABASE_URL`` should contain the connection data for connecting to
|
||||
your Postgres database. It takes the form
|
||||
``postgres://username:password@server_addr/database_name``.
|
||||
|
||||
- ``SITE_URL`` should be set to the URL you will use to connect to your
|
||||
local development site. Some people prefer to use
|
||||
``http://127.0.0.1:8000`` instead of ``localhost``.
|
||||
|
||||
5. Initialize your database by running the migrations:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
python manage.py migrate
|
||||
|
||||
6. Create a new superuser account:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
python manage.py createsuperuser
|
||||
|
||||
Make sure that the email address you use for the superuser account matches
|
||||
the email that you will log in with via Persona.
|
||||
|
||||
7. Pull the latest strings from version control for the Pontoon Intro project
|
||||
(which is automatically created for you during the database migrations):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
python manage.py update_projects
|
||||
|
||||
8. Install the required Node libraries using ``npm``:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
npm install
|
||||
|
||||
Once you've finished these steps, you should be able to start the site by
|
||||
running:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
docker-compose up
|
||||
python manage.py runserver
|
||||
|
||||
If you're running Docker directly (via Linux), the site should be available at
|
||||
http://localhost:8000. If you're running boot2docker, the site should be
|
||||
available on port 8000 at the IP output by running:
|
||||
The site should be available at http://localhost:8000.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
boot2docker ip
|
||||
|
||||
For admin_ access, create admin account with:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
docker-compose run web ./manage.py createsuperuser
|
||||
|
||||
.. _Install Docker and Compose: https://docs.docker.com/compose/install/
|
||||
.. _peep: https://github.com/erikrose/peep/
|
||||
.. _fork: http://help.github.com/fork-a-repo/
|
||||
.. _boot2docker: http://boot2docker.io/
|
||||
.. _admin: http://localhost:8000/admin/
|
||||
|
||||
Local settings
|
||||
Extra settings
|
||||
--------------
|
||||
The following settings can be set by creating a `.env` file in root directory of
|
||||
your pontoon repo and adding their values:
|
||||
|
||||
```
|
||||
MICROSOFT_TRANSLATOR_API_KEY=microsoft-key
|
||||
GOOGLE_ANALYTICS_KEY=google-key
|
||||
MOZILLIANS_API_KEY=mozillians-key
|
||||
```
|
||||
The following extra settings can be added to your ``.env`` file.
|
||||
|
||||
``MICROSOFT_TRANSLATOR_API_KEY``
|
||||
Set your `Microsoft Translator API key`_ to use machine translation.
|
||||
|
|
|
@ -9,16 +9,15 @@ You can run the automated test suite with the following command:
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
docker-compose run web ./manage.py test
|
||||
python manage.py test
|
||||
|
||||
Updating Your Local Instance
|
||||
----------------------------
|
||||
When changes are merged to the main Pontoon repository, you'll want to update
|
||||
your local development instance to reflect the latest version of the site. You
|
||||
can use Git as normal to pull the latest changes, but if the changes add any new
|
||||
dependencies or alter the ``Dockerfile`` or ``docker-compose.yml`` files, you'll
|
||||
want to re-build your Docker container. In addition, if the database has been
|
||||
changed, you'll want to run any new migrations.
|
||||
dependencies or alter the database, you'll want to install any new libraries and
|
||||
run any new migrations.
|
||||
|
||||
If you're unsure what needs to be run, it's safe to just perform all of these
|
||||
steps, as they don't affect your setup if nothing has changed:
|
||||
|
@ -28,11 +27,11 @@ steps, as they don't affect your setup if nothing has changed:
|
|||
# Pull latest code (assuming you've already checked out master).
|
||||
git pull origin master
|
||||
|
||||
# Re-build the container.
|
||||
docker-compose build
|
||||
# Install new dependencies or update existing ones.
|
||||
./bin/peep.py install -r requirements.txt
|
||||
|
||||
# Run database migrations.
|
||||
docker-compose run web ./manage.py migrate
|
||||
python manage.py migrate
|
||||
|
||||
Building the Documentation
|
||||
--------------------------
|
||||
|
@ -40,7 +39,9 @@ You can build the documentation with the following command:
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
docker-compose run web ./bin/build-docs.sh
|
||||
# Enter the docs/ subdirectory
|
||||
cd docs
|
||||
make html
|
||||
|
||||
After running this command, the documentation should be available at
|
||||
``docs/_build/html/index.html``.
|
||||
|
|
Загрузка…
Ссылка в новой задаче