Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐳 Refactor docker compose #1159

Merged
merged 10 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
version: '3.6'
services:
# Update this to the name of the service you want to work with in your docker-compose.yml file
# Update this to the name of the service you want to work with in your compose.yml file
django:
# Uncomment if you want to override the service's Dockerfile to one in the .devcontainer
# folder. Note that the path of the Dockerfile and context is relative to the *primary*
# docker-compose.yml file (the first in the devcontainer.json "dockerComposeFile"
# compose.yml file (the first in the devcontainer.json "dockerComposeFile"
# array). The sample below assumes your primary file is in the root of your project.
#
# build:
Expand Down
10 changes: 5 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
{
"name": "Existing Docker Compose (Extend)",
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
// The .devcontainer/compose.yml file contains any overrides you need/want to make.
"dockerComposeFile": [
"../docker-compose.yml",
"docker-compose.yml"
"../compose.yml",
"compose.yml"
],
"initializeCommand": ".devcontainer/create_dot_env.sh",
"customizations": {
Expand Down Expand Up @@ -52,10 +52,10 @@
// mentioned in https://github.com/microsoft/vscode-remote-release/issues/5317
"updateRemoteUserUID": false,
// The 'service' property is the name of the service for the container that VS Code should
// use. Update this value and .devcontainer/docker-compose.yml to the real service name.
// use. Update this value and .devcontainer/compose.yml to the real service name.
"service": "django",
// The optional 'workspaceFolder' property is the path VS Code should open by default when
// connected. This is typically a file mount in .devcontainer/docker-compose.yml
// connected. This is typically a file mount in .devcontainer/compose.yml
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
Expand Down
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
.gitignore
.pytest_cache
.rsync-exclude-from
compose*.yml
CONTRIBUTORS.txt
data
design
Expand Down
4 changes: 2 additions & 2 deletions .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ DJANGO_DEBUG=True
DJANGO_MAILGUN_API_KEY=
DJANGO_SENTRY_DSN=
DJANGO_SETTINGS_MODULE=settings.docker
FRAMEWORK_TITLE=Django Packages
FRAMEWORK_TITLE="Django Packages"
GITHUB_API_SECRET=your-github-api-secret
GITHUB_APP_ID=your-github-app-id
GITHUB_TOKEN=your-github-token
Expand All @@ -25,5 +25,5 @@ PYPI_HEALTHCHECK_URL=
REDIS_URL=redis://redis
SEARCHV2_HEALTHCHECK_URL=
SECRET_KEY=your-secret-key
SITE_TITLE=Django Packages
SITE_TITLE="Django Packages"
TLS_EMAIL=
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ crashlytics-build.properties
fabric.properties

# docker
compose.override.yml
docker-compose.override.yml

# our files
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,23 @@ To download, install and start the local server for development, simply run:
git clone git@github.com:djangopackages/djangopackages.git
cd djangopackages
cp .env.local.example .env.local
docker-compose build
docker-compose up
docker compose build
docker compose up
```

Then point your browser to http://localhost:8000 and start hacking!

If you are running into conflicting port issues, we have an override file which re-maps Django (port: 18000) and Postgres (port: 45432). To activate it, simply run:

```shell
cp docker-compose.override.yml.example docker-compose.override.yml
docker-compose build
docker-compose up
docker compose build
docker compose up
````

To run tests, run:

```shell
docker-compose run django pytest
docker compose run django pytest
```

## The Site
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion docker-compose.yml → compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ services:

django-q:
<<: *common-settings
command: ["python", "manage.py", "qcluster"]
command: ["python", "-m", manage", "qcluster"]
init: true

postgres:
Expand Down
2 changes: 1 addition & 1 deletion core/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2024.5.6"
__version__ = "2024.5.7"
18 changes: 0 additions & 18 deletions docker-compose.override.yml.example

This file was deleted.

2 changes: 1 addition & 1 deletion docker-supervisord.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[program:djangopackages]
command=docker-compose up
command=docker compose up
directory=/code/djangopackages
redirect_stderr=true
autostart=true
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/django/start-dev.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/sh
python -m manage migrate --noinput

python -m manage runserver 0.0.0.0:8000
4 changes: 2 additions & 2 deletions docs/docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ We want your submission. But we also want to provide a stable experience for our
Before you submit a pull request, please run the entire Django Packages test suite via:

```shell
docker-compose run django pytest
docker compose run django pytest
```

The first thing the core committers will do is run this command. Any pull request that fails this test suite will be **rejected**.
Expand Down Expand Up @@ -182,7 +182,7 @@ git pull git://github.com/<submitter-github-name/djangopackages.git develop
Then we run the tests:

```shell
python manage.py test --settings=settings.test
python -m manage test --settings=settings.test
```

We finish with a merge and push to GitHub:
Expand Down
10 changes: 5 additions & 5 deletions docs/docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The current strategy is:

## Stack

All of our `docker-compose*.yml` configurations contains the following services:
All of our `compose*.yml` configurations contains the following services:

- `postgres` powers our database.
- `django` powers our Python and Django backend. In production we use call these `django-a` and `django-b` to run our WSGI server and serves the app through gunicorn.
Expand Down Expand Up @@ -43,7 +43,7 @@ just deploy
Our static media files are behind a CDN. We occasionally need to purge cached files. To purge the cache:

```shell
docker-compose run django cli4 --delete purge_everything=true /zones/:djangopackages.org/purge_cache
docker compose run django cli4 --delete purge_everything=true /zones/:djangopackages.org/purge_cache
```

Alternatively, you can use `just`
Expand All @@ -70,21 +70,21 @@ just purge_cache

```shell
cd /code/djangopackages
docker-compose ps
docker compose ps
```

- Check the logs for all services:

```shell
cd /code/djangopackages
docker-compose logs
docker compose logs
```

- Check the logs for individual services:

```shell
cd /code/djangopackages
docker-compose logs postgres|django-a|django-b|caddy
docker compose logs postgres|django-a|django-b|caddy
```

[Fabric]: https://www.fabfile.org/
14 changes: 7 additions & 7 deletions docs/docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You'll want to make sure your local environment is ready by installing the follo

### Docker

If you don't have them installed yet, install [Docker] and [docker-compose].
If you don't have them installed yet, install [Docker] and [Compose].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mention the minimum required versions here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea. I don't know what the minimum should be.


### Grab a Local Copy of the Project

Expand All @@ -35,10 +35,10 @@ cp .env.local.example .env.local

### Build the Docker Containers

Now build the project using docker-compose:
Now build the project using Docker Compose:

```shell
docker-compose build
docker compose build
```

### Add A GitHub API Token (optional)
Expand All @@ -52,7 +52,7 @@ metadata, and required for certain tests.
To start the project, run:

```shell
docker-compose up --detach
docker compose up --detach
```

Then point your browser to <http://localhost:8000> and start hacking!
Expand All @@ -64,7 +64,7 @@ Now, you'll give yourself an admin account on the locally-running version of Dja
Create a Django superuser for yourself, replacing joe with your username/email:

```shell
docker-compose run django python manage.py createsuperuser --username=joe --email=joe@example.com
docker compose run django python -m manage createsuperuser --username=joe --email=joe@example.com
```

And then login into the admin interface (/admin/) and create a profile for your user filling all the fields with any data.
Expand All @@ -74,7 +74,7 @@ And then login into the admin interface (/admin/) and create a profile for your
We use a **Mock** system of creating sample data in our tests and for running a development version of the site. To create some development data, just run:

```shell
docker-compose run --rm django python manage.py load_dev_data
docker compose run --rm django python -m manage load_dev_data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

```

### Formatters, Linters, and other miscellanea
Expand Down Expand Up @@ -104,7 +104,7 @@ pre-commit run ruff

A more [opinionated] set up using the command runner `just` is also available.

[docker-compose]: https://docs.docker.com/compose/install/
[compose]: https://docs.docker.com/compose/install/
[docker]: https://docs.docker.com/install/
[just]: https://github.com/casey/just
[opinionated]: install_opinionated.md
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/install_opinionated.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ You'll want to make sure your local environment is ready by installing the follo

### Docker

If you don't have them installed yet, install [Docker] and [docker-compose].
If you don't have them installed yet, install [Docker] and [Compose].

### Grab a Local Copy of the Project

Expand Down Expand Up @@ -37,7 +37,7 @@ metadata, and required for certain tests.

### Build the Docker Containers

Now build the project using docker-compose:
Now build the project using docker compose:

```shell
just build
Expand Down Expand Up @@ -101,7 +101,7 @@ To run a pre-commit rule by hand:
pre-commit run ruff
```

[docker-compose]: https://docs.docker.com/compose/install/
[compose]: https://docs.docker.com/compose/install/
[docker]: https://docs.docker.com/install/
[just]: https://github.com/casey/just
[opinionated]: install_opinionated.md
Expand Down
Loading