Skip to content

Commit f59b946

Browse files
committed
add means to build/watch assets in docker as well
1 parent eda5982 commit f59b946

File tree

4 files changed

+89
-9
lines changed

4 files changed

+89
-9
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

Dockerfile.assets

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM node:18-slim
2+
3+
# Install rsync
4+
RUN apt-get update && \
5+
apt-get install -y rsync && \
6+
rm -rf /var/lib/apt/lists/*
7+
8+
WORKDIR /app
9+
10+
# Create necessary directories
11+
RUN mkdir -p src/javascripts \
12+
src/scss \
13+
application/static/javascripts \
14+
application/static/stylesheets
15+
16+
# Set shell environment variable
17+
ENV SHELL=/bin/bash
18+
19+
# Copy package files
20+
COPY package*.json ./
21+
22+
# Install dependencies without running scripts
23+
RUN npm install --ignore-scripts
24+
25+
# Set default command
26+
CMD ["npm", "run", "watch"]

README.md

+26-9
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,44 @@ Manage planning considerations through standards process
1010
node 18
1111
postgresql
1212

13-
For loading data into db:
1413

15-
heroku-cli
14+
## Running the app locally with docker
1615

17-
[heroku-cli](https://devcenter.heroku.com/articles/heroku-cli)
16+
### First time setup or when you need to rebuild assets
17+
18+
docker compose run --rm assets-build
19+
20+
### Regular development (starts everything)
21+
22+
docker compose up
23+
24+
### When you need to restore the database
25+
26+
docker compose down -v
27+
docker compose up
1828

1929

20-
## Get started
30+
## To run the app locally without docker
2131

2232
createdb dluhc-planning-considerations
2333
make init
2434

25-
## Apply db migrations
35+
### Apply db migrations
2636
flask db upgrade
2737

2838

29-
## Load/update consideration data
39+
### For loading data into db you'll need the heroku-cli
40+
41+
heroku-cli
42+
43+
[heroku-cli](https://devcenter.heroku.com/articles/heroku-cli)
44+
45+
46+
### Load/update consideration data
3047

3148
flask consider load-data
3249

33-
## Load/update questions
50+
### Load/update questions
3451

3552
Questions are [here](application/question_sets.py)
3653

@@ -42,12 +59,12 @@ To add/edit a question make changes [here](application/question_sets.py) then ru
4259

4360
Fix any errors then run the load command above
4461

45-
## Run app locally
62+
### Run app locally
4663

4764
flask run
4865

4966

50-
## To test authentication in local development
67+
### To test authentication in local development
5168

5269
Set the following in DevelopmentConfig
5370

compose.yml

+36
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,20 @@ services:
88
- action: sync
99
path: .
1010
target: /code
11+
ignore:
12+
- node_modules/
13+
- .git/
14+
- action: rebuild
15+
path: requirements.txt
16+
volumes:
17+
- .:/code
1118
depends_on:
1219
- db
1320
environment:
1421
SECRET_KEY: "replaceinprod"
1522
DATABASE_URL: "postgresql://postgres:password@db/planning-data-design"
23+
FLASK_DEBUG: 1
24+
PYTHONDONTWRITEBYTECODE: 1
1625
networks:
1726
- app-network
1827

@@ -34,8 +43,35 @@ services:
3443
networks:
3544
- app-network
3645

46+
assets:
47+
build:
48+
context: .
49+
dockerfile: Dockerfile.assets
50+
volumes:
51+
- .:/app
52+
- node_modules:/app/node_modules
53+
environment:
54+
- NODE_ENV=development
55+
- SHELL=/bin/bash
56+
command: npm run watch
57+
depends_on:
58+
- web
59+
60+
# Optional one-time build service
61+
assets-build:
62+
build:
63+
context: .
64+
dockerfile: Dockerfile.assets
65+
volumes:
66+
- .:/app
67+
- node_modules:/app/node_modules
68+
command: npm run postinstall
69+
profiles:
70+
- build
71+
3772
volumes:
3873
pgdata:
74+
node_modules: # Persist node_modules to avoid reinstalling on every restart
3975

4076
networks:
4177
app-network:

0 commit comments

Comments
 (0)