Skip to content

Commit 2819b26

Browse files
vanessavmacmihow
andauthored
Updates to README and initial project setup (#552)
* Redirect to api/v2 * Update README, fix code formatting docs: update instructions about pre-commit and backend dependencies fix: make homepage redirect a temporary redirect because the API version will change * Use urljoin * fix: keep name of route for home page * fix: ui configuration in compose stack --------- Co-authored-by: Michael Bunsen <notbot@gmail.com>
1 parent 3818f9b commit 2819b26

File tree

4 files changed

+42
-24
lines changed

4 files changed

+42
-24
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ The platform uses Docker Compose to run all services locally for development. In
1717

1818
## Development
1919

20+
Install the pre-commit tool to run linting & formatting checks _before_ each git commit. It's typical to install this tool using your system-wide python.
21+
22+
```
23+
pip install pre-commit # Install pre-commit system-wide
24+
pre-commit install # Install the hook for our project
25+
```
26+
27+
If using VS Code, install the formatting extensions that are automatically suggested for the project (e.g. black). Format-on-save should be turned on by default from the project's vscode settings file.
28+
29+
2030
### Frontend
2131

2232
#### Dependencies
@@ -55,6 +65,13 @@ Visit http://localhost:3000/
5565
- [Docker](https://docs.docker.com/get-docker/)
5666
- [Docker Compose](https://docs.docker.com/compose/install/)
5767

68+
All backend packages are installed in the docker containers, however for faster auto-completion and intellisense, you can install them on the host machine:
69+
70+
```bash
71+
python -m venv venv
72+
source venv/bin/activate
73+
pip install -r requirements/local.txt
74+
```
5875

5976
#### Helpful Commands
6077

compose/local/ui/Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# Node version should always match the version in `ui/.nvmrc`
22
FROM node:18
33
WORKDIR /app
4-
USER node
54
COPY package.json yarn.lock ./
65
RUN yarn install
7-
COPY . .
86
RUN ["git", "config", "--global", "--add", "safe.directory", "/app"]
97
ENV BROWSER=none
108
CMD ["yarn", "start", "--host", "0.0.0.0" , "--port", "4000"]

config/urls.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1+
from urllib.parse import urljoin
2+
13
from django.conf import settings
24
from django.conf.urls.static import static
35
from django.contrib import admin
46
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
57
from django.urls import include, path
68
from django.views import defaults as default_views
7-
from django.views.generic import TemplateView
9+
from django.views.generic import RedirectView
810
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView
911

12+
API_ROOT = "api/v2/"
13+
1014
urlpatterns = [
11-
path("", TemplateView.as_view(template_name="pages/home.html"), name="home"),
12-
path("about/", TemplateView.as_view(template_name="pages/about.html"), name="about"),
15+
# Redirect homepage to API_ROOT
16+
path("", RedirectView.as_view(url=API_ROOT, permanent=False), name="home"),
1317
# Django Admin, use {% url 'admin:index' %}
1418
path(settings.ADMIN_URL, admin.site.urls),
1519
# Your stuff: custom urls includes go here
@@ -21,11 +25,11 @@
2125
# API URLS
2226
urlpatterns += [
2327
# API base url
24-
path("api/v2/", include("config.api_router", namespace="api")),
28+
path(API_ROOT, include("config.api_router", namespace="api")),
2529
# OpenAPI Docs
26-
path("api/v2/schema/", SpectacularAPIView.as_view(api_version="api"), name="api-schema"),
30+
path(urljoin(API_ROOT, "schema/"), SpectacularAPIView.as_view(api_version="api"), name="api-schema"),
2731
path(
28-
"api/v2/docs/",
32+
urljoin(API_ROOT, "docs/"),
2933
SpectacularSwaggerView.as_view(url_name="api-schema"),
3034
name="api-docs",
3135
),

docker-compose.yml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,21 @@ services:
4343
env_file:
4444
- ./.envs/.local/.postgres
4545

46-
# ui:
47-
# image: ami_local_ui
48-
# build:
49-
# context: ./ui
50-
# dockerfile: ../compose/local/ui/Dockerfile
51-
# ports:
52-
# - "4000:4000"
53-
# volumes:
54-
# - ./.git:/app/.git:ro
55-
# - ./ui:/app
56-
# - /app/node_modules
57-
# depends_on:
58-
# - django
59-
# environment:
60-
# - CHOKIDAR_USEPOLLING=true
61-
# - API_PROXY_TARGET=http://django:8000
46+
ui:
47+
image: ami_local_ui
48+
build:
49+
context: ./ui
50+
dockerfile: ../compose/local/ui/Dockerfile
51+
ports:
52+
- "4000:4000"
53+
volumes:
54+
- ./.git:/app/.git:ro
55+
- ./ui:/app
56+
depends_on:
57+
- django
58+
environment:
59+
- CHOKIDAR_USEPOLLING=true
60+
- API_PROXY_TARGET=http://django:8000
6261

6362
docs:
6463
image: ami_local_docs

0 commit comments

Comments
 (0)