-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docker-compose: tweaks to work on an M1 MacBook
* Install PostgreSQL v12 instead of latest v15. * Introduce SAUCE_OS variable to download compatible Sauce Connect. * Extend installation docs on Docker Compose to reflect experience. * Build psycopg2 from source instead of using psycopg2-binary.
- Loading branch information
1 parent
6d131df
commit 28ebeb0
Showing
7 changed files
with
25 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -326,26 +326,33 @@ on the Kubernetes cluster at CERN. | |
|
||
For local development you can use the ``docker-compose.yml`` file to run the HEPData Docker image and its required services. | ||
|
||
First, ensure you have installed `Docker <https://docs.docker.com/install/>`_ and `Docker Compose <https://docs.docker.com/compose/install/>`__. | ||
First, ensure you have installed `Docker <https://docs.docker.com/install/>`_ and `Docker Compose <https://docs.docker.com/compose/install/>`_. | ||
|
||
Copy the file ``config_local.docker_compose.py`` to ``config_local.py``. | ||
|
||
In order to run the tests via Sauce Labs, ensure you have the variables ``$SAUCE_USERNAME`` and ``$SAUCE_ACCESS_KEY`` | ||
set in your environment (see :ref:`running-the-tests`) **before** starting the containers. | ||
|
||
If using an M1 MacBook, also add ``export SAUCE_OS=linux-arm64`` to your bash or zsh profile. This is necessary to | ||
download the correct `Sauce Connect Proxy | ||
<https://docs.saucelabs.com/secure-connections/sauce-connect/installation/#downloading-sauce-connect-proxy>`_ | ||
client. | ||
|
||
Start the containers: | ||
|
||
.. code-block:: console | ||
$ docker-compose up | ||
(This starts containers for all the 5 necessary services. See :ref:`docker-compose-tips` if you only want to run some containers.) | ||
(This starts containers for all the 6 necessary services. See :ref:`docker-compose-tips` if you only want to run some containers.) | ||
|
||
In another terminal, initialise the database: | ||
|
||
.. code-block:: console | ||
$ docker-compose exec web bash -c "hepdata utils reindex -rc True" # ignore error "hepsubmission" does not exist | ||
$ docker-compose exec web bash -c "mkdir -p /code/tmp; ./scripts/initialise_db.sh [email protected] password" | ||
$ docker-compose exec db bash -c "psql hepdata -U hepdata -c 'update accounts_user set confirmed_at=NOW() where id=1;'" | ||
Now open http://localhost:5000/ and HEPData should be up and running. (It may take a few minutes for Celery to process | ||
the sample records.) | ||
|
@@ -354,16 +361,19 @@ To run the tests: | |
|
||
.. code-block:: console | ||
$ docker-compose exec web bash -c "/usr/local/var/sc-4.8.1-linux/bin/sc -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY --region eu-central & ./run-tests.sh" | ||
$ docker-compose exec web bash -c "/usr/local/var/sc-4.8.1-${SAUCE_OS:-linux}/bin/sc -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY --region eu-central & ./run-tests.sh" | ||
On an M1 MacBook, the end-to-end tests failed with ``WARNING: security - Error with Permissions-Policy header: | ||
Unrecognized feature: 'interest-cohort'.`` and the ``assert len(log) == 0`` line in ``tests/e2e/conftest.py`` had to be | ||
commented out for all tests to pass. | ||
|
||
.. _docker-compose-tips: | ||
|
||
Tips | ||
==== | ||
|
||
* If you see errors about ports already being allocated, ensure you're not running any of the services another way (e.g. hepdata-converter via Docker). | ||
* If you want to run just some of the containers, specify their names in the docker-compose command. For example, to just run the web server, database and OpenSearch, run: | ||
* If you want to run just some of the containers, specify their names in the ``docker-compose`` command. For example, to just run the web server, database and OpenSearch, run: | ||
|
||
.. code-block:: console | ||
|
@@ -372,9 +382,12 @@ Tips | |
See ``docker-compose.yml`` for the names of each service. Running a subset of containers could be useful in the following cases: | ||
|
||
* You want to use the live converter service, i.e. ``CFG_CONVERTER_URL = 'https://converter.hepdata.net'`` instead of running the converter locally. | ||
* You want to run the container for the web service by pulling an image from DockerHub instead of building an image locally. | ||
* You want to run the container for the web service by pulling an image from Docker Hub instead of building an image locally. | ||
* You want to run containers for all services apart from web (and maybe converter) then use a non-Docker web service. | ||
|
||
If using Docker Desktop, you need to use ``host.docker.internal`` instead of ``localhost`` when `connecting from a | ||
container to a service on the host <https://docs.docker.com/desktop/networking/#use-cases-and-workarounds-for-all-platforms>`_. | ||
|
||
* To run the containers in the background, run: | ||
|
||
.. code-block:: console | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM postgres | ||
FROM postgres:12 | ||
|
||
# Custom initialization scripts | ||
COPY ./create_test_db.sh /docker-entrypoint-initdb.d/20-create_test_db.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,4 @@ | |
and parsed by ``setup.py``. | ||
""" | ||
|
||
__version__ = "0.9.4dev20221110" | ||
__version__ = "0.9.4dev20221111" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters