File tree Expand file tree Collapse file tree 3 files changed +77
-4
lines changed Expand file tree Collapse file tree 3 files changed +77
-4
lines changed Original file line number Diff line number Diff line change 19
19
** /Thumbs.db
20
20
.github /
21
21
docs /
22
+ node_modules /
22
23
public /bundles /
23
24
tests /
24
25
var /
Original file line number Diff line number Diff line change @@ -31,10 +31,11 @@ A [Docker](https://www.docker.com/)-based installer and runtime for the [Symfony
31
31
1 . [ Build options] ( docs/build.md )
32
32
2 . [ Using Symfony Docker with an existing project] ( docs/existing-project.md )
33
33
3 . [ Support for extra services] ( docs/extra-services.md )
34
- 4 . [ Deploying in production] ( docs/production.md )
35
- 5 . [ Debugging with Xdebug] ( docs/xdebug.md )
36
- 6 . [ Using a Makefile] ( docs/makefile.md )
37
- 7 . [ Troubleshooting] ( docs/troubleshooting.md )
34
+ 4 . [ Building CSS and JS] ( docs/build-css-js.md )
35
+ 5 . [ Deploying in production] ( docs/production.md )
36
+ 6 . [ Debugging with Xdebug] ( docs/xdebug.md )
37
+ 7 . [ Using a Makefile] ( docs/makefile.md )
38
+ 8 . [ Troubleshooting] ( docs/troubleshooting.md )
38
39
39
40
## Credits
40
41
Original file line number Diff line number Diff line change
1
+ # Building CSS and JS
2
+
3
+ For security reason and limit the size of the container, the default stack doesn't include any development "artifacts".
4
+ To add it to the project and your development workflow follow this guide.
5
+
6
+ * This example uses ` npm ` and [ Webpack Encore] ( https://symfony.com/doc/current/frontend.html ) .*
7
+
8
+ Modify ` Dockerfile ` to build your assets :
9
+
10
+ - At the top of the file before anything else
11
+ ``` diff
12
+ ARG PHP_VERSION=8.1
13
+ ARG CADDY_VERSION=2
14
+ + ARG NODE_VERSION=18
15
+ +
16
+ + # node "stage"
17
+ + FROM node:${NODE_VERSION}-alpine AS symfony_node
18
+ +
19
+ + WORKDIR /srv/app
20
+ +
21
+ + COPY package*.json ./
22
+ +
23
+ + RUN npm install
24
+ + ## If you are building your code for production
25
+ + # RUN npm ci --only=production
26
+ +
27
+ + ## You need to copy everything to use PostCSS, Tailwinds, ...
28
+ + COPY . .
29
+ +
30
+ + RUN npm run build
31
+
32
+ # "php" stage
33
+ ```
34
+
35
+ - Then copy the built output in ` public/build ` (the configuration default) to the ` php ` container (which will then be copied later to ` caddy ` ).
36
+
37
+ ``` diff
38
+ VOLUME /srv/app/var
39
+
40
+ + COPY --from=symfony_node /srv/app/public/build public/build
41
+
42
+ ENTRYPOINT ["docker-entrypoint"]
43
+ CMD ["php-fpm"]
44
+
45
+ FROM caddy:${CADDY_VERSION}-builder-alpine AS symfony_caddy_builder
46
+ ```
47
+
48
+ Modify ` docker-compose.override.yml ` to add a ` node ` container in your development environment.
49
+ This will provide you with hot module reloading.
50
+
51
+ ``` diff
52
+ caddy:
53
+ volumes:
54
+ - ./docker/caddy/Caddyfile:/etc/caddy/Caddyfile:ro
55
+ - ./public:/srv/app/public:ro
56
+
57
+ + node:
58
+ + build:
59
+ + context: .
60
+ + target: symfony_node
61
+ + volumes:
62
+ + - ./:/srv/app
63
+ + ports:
64
+ + - target: 8080
65
+ + published: 8080
66
+ + protocol: tcp
67
+ + command: 'sh -c "npm install; npm run dev-server -- --server-type https --client-web-socket-url https://localhost:8080 --host 0.0.0.0"'
68
+ ```
69
+
70
+ If file changes are not picked up, refer to this page:
71
+ https://symfony.com/doc/current/frontend/encore/virtual-machine.html#file-watching-issues
You can’t perform that action at this time.
0 commit comments