You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/2-local-development/developing-locally-docker.rst
+21-3
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,24 @@ This can take a while, especially the first time you run this particular command
36
36
37
37
Generally, if you want to emulate production environment use ``docker-compose.production.yml`` instead. And this is true for any other actions you might need to perform: whenever a switch is required, just do it!
38
38
39
+
After we have created our initial image we nee to generate a lockfile for our dependencies.
40
+
Docker cannot write to the host system during builds, so we have to run the command to generate the lockfile in the container.
41
+
This is important for reproducible builds and to ensure that the dependencies are installed correctly in the container.
42
+
Updating the lockfile manually is normally not necessary when you add packages through `uv add <package_name>`.
43
+
44
+
$ docker compose -f docker-compose.local.yml run --rm django uv lock
45
+
46
+
This is done by running the following command: ::
47
+
48
+
$ docker compose -f docker-compose.local.yml run --rm django uv lock
49
+
50
+
To be sure we are on the right track we need to build our image again: ::
Before doing any git commit, `pre-commit`_ should be installed globally on your local machine, and then::
40
58
41
59
$ git init
@@ -154,10 +172,10 @@ This tells our computer that all future commands are specifically for the dev1 m
154
172
Add 3rd party python packages
155
173
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
156
174
157
-
To install a new 3rd party python package, you cannot use ``pip install <package_name>``, that would only add the package to the container. The container is ephemeral, so that new library won't be persisted if you run another container. Instead, you should modify the Docker image:
158
-
You have to modify the relevant requirement file: base, local or production by adding: ::
175
+
To install a new 3rd party python package, you cannot use ``uv add <package_name>``, that would only add the package to the container. The container is ephemeral, so that new library won't be persisted if you run another container. Instead, you should modify the Docker image:
176
+
You have to modify pyproject.toml and either add it to project.dependencies or to tool.uv.dev-dependencies by adding: ::
159
177
160
-
<package_name>==<package_version>
178
+
"<package_name>==<package_version>"
161
179
162
180
To get this change picked up, you'll need to rebuild the image(s) and restart the running container: ::
$ uv run uvicorn config.asgi:application --host 0.0.0.0 --reload --reload-include '*.html'
83
73
84
74
If you've opted for Webpack or Gulp as frontend pipeline, please see the :ref:`dedicated section <bare-metal-webpack-gulp>` below.
85
75
@@ -136,7 +126,7 @@ Following this structured approach, here's how to add a new app:
136
126
137
127
#. **Create the app** using Django's ``startapp`` command, replacing ``<name-of-the-app>`` with your desired app name: ::
138
128
139
-
$ python manage.py startapp <name-of-the-app>
129
+
$ uv run python manage.py startapp <name-of-the-app>
140
130
141
131
#. **Move the app** to the Django Project Root, maintaining the project's two-tier structure: ::
142
132
@@ -203,14 +193,14 @@ Next, make sure `redis-server` is installed (per the `Getting started with Redis
203
193
204
194
Start the Celery worker by running the following command in another terminal::
205
195
206
-
$ celery -A config.celery_app worker --loglevel=info
196
+
$ uv run celery -A config.celery_app worker --loglevel=info
207
197
208
198
That Celery worker should be running whenever your app is running, typically as a background process,
209
199
so that it can pick up any tasks that get queued. Learn more from the `Celery Workers Guide`_.
210
200
211
201
The project comes with a simple task for manual testing purposes, inside `<project_slug>/users/tasks.py`. To queue that task locally, start the Django shell, import the task, and call `delay()` on it::
212
202
213
-
$ python manage.py shell
203
+
$ uv run python manage.py shell
214
204
>> from <project_slug>.users.tasks import get_users_count
0 commit comments