File tree Expand file tree Collapse file tree 10 files changed +100
-9
lines changed
Expand file tree Collapse file tree 10 files changed +100
-9
lines changed Original file line number Diff line number Diff line change 4949 # Prepend any command with "nx-cloud record --" to record its logs to Nx Cloud
5050 # - run: npx nx-cloud record -- echo Hello World
5151 # Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected
52- - run : npx nx affected -t lint test build typecheck docker-build
52+ - run : npx nx affected -t lint test build typecheck
5353
5454 - name : Version
5555 env :
7575 npx nx release publish --group packages --yes
7676 env :
7777 THDK_GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
78+
79+ # Excluding dependendencies as they should have been already executed and
80+ # we can't rely on the cache to detect the dependencies no longer need to be ran
81+ # since it is busted by writing versions to generated pacakge.json files
82+ - name : Containerize
83+ run : |
84+ npx nx run-many --target docker-build --exclude-task-dependencies
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ RUN chown -R books-api:books-api .
1919
2020# You can remove this install step if you build with `--bundle` option.
2121# The bundled output will include external dependencies.
22- RUN npm --prefix books-api --omit=dev -f install
22+ RUN --mount=type=cache,target=/root/.npm \
23+ npm --prefix books-api ci
2324
2425CMD [ "node" , "books-api" ]
Original file line number Diff line number Diff line change 2929 }
3030 }
3131 },
32- "docker-build" : {
33- "dependsOn" : [" build" ],
34- "command" : " docker build -f apps/books-api/Dockerfile . -t books-api"
35- }
32+ "docker-build" : {},
33+ "docker-run" : {}
3634 }
3735}
Original file line number Diff line number Diff line change 1+ # This file is generated by Nx.
2+ #
3+ # Build the docker image with `npx nx docker-build books-app`.
4+ # Tip: Modify "docker-build" options in project.json to change docker build args.
5+ #
6+ # Run the container with `docker run -p 3000:3000 -t books-app`.
7+ FROM docker.io/node:lts-alpine
8+
9+ ENV HOST=0.0.0.0
10+ ENV PORT=3000
11+
12+ WORKDIR /app
13+
14+ RUN addgroup --system books-app && \
15+ adduser --system -G books-app books-app
16+
17+ COPY dist/apps/books-app books-app/
18+ RUN chown -R books-app:books-app .
19+
20+ # You can remove this install step if you build with `--bundle` option.
21+ # The bundled output will include external dependencies.
22+ RUN --mount=type=cache,target=/root/.npm \
23+ npm --prefix books-app ci
24+
25+ WORKDIR /app/books-app
26+ CMD [ "npm" , "run" , "start" ]
Original file line number Diff line number Diff line change 1010 "@remix-run/serve" : " ^2.14.0" ,
1111 "isbot" : " ^4.4.0" ,
1212 "react" : " ^18.2.0" ,
13- "react-dom" : " ^18.2.0"
13+ "react-dom" : " ^18.2.0" ,
14+ "ms" : " ^2.1.3"
1415 },
1516 "devDependencies" : {
1617 "@remix-run/dev" : " ^2.14.0" ,
Original file line number Diff line number Diff line change 1414 "generateLockfile" : true ,
1515 "includeDevDependenciesInPackageJson" : false
1616 }
17+ },
18+ "docker-build" : {},
19+ "docker-run" : {
20+ "options" : {
21+ "command" : [
22+ " docker run -it --rm --init" ,
23+ " -p 3002:3002" ,
24+ " --env API_URL" ,
25+ " --env PORT" ,
26+ " books-app"
27+ ]
28+ }
1729 }
1830 }
1931}
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ export default defineConfig({
1212 root : __dirname ,
1313 cacheDir : '../../node_modules/.vite/apps/books-app' ,
1414 server : {
15- port : 4200 ,
15+ port : process . env . PORT ? Number ( process . env . PORT ) : 4200 ,
1616 host : 'localhost' ,
1717 } ,
1818 preview : {
Original file line number Diff line number Diff line change 1+ # This file is generated by Nx.
2+ #
3+ # Build the docker image with `npx nx docker-build hello-api`.
4+ # Tip: Modify "docker-build" options in project.json to change docker build args.
5+ #
6+ # Run the container with `docker run -p 3000:3000 -t hello-api`.
7+ FROM docker.io/node:lts-alpine
8+
9+ ENV HOST=0.0.0.0
10+ ENV PORT=3000
11+
12+ WORKDIR /app
13+
14+ RUN addgroup --system hello-api && \
15+ adduser --system -G hello-api hello-api
16+
17+ COPY dist/apps/hello-api hello-api/
18+ RUN chown -R hello-api:hello-api .
19+
20+ # You can remove this install step if you build with `--bundle` option.
21+ # The bundled output will include external dependencies.
22+ RUN --mount=type=cache,target=/root/.npm \
23+ npm --prefix hello-api ci
24+
25+ CMD [ "node" , "hello-api" ]
Original file line number Diff line number Diff line change 3333 "options" : {
3434 "passWithNoTests" : true
3535 }
36- }
36+ },
37+ "docker-build" : {},
38+ "docker-run" : {}
3739 }
3840}
Original file line number Diff line number Diff line change 8484 "cache" : true ,
8585 "dependsOn" : [" ^build" ],
8686 "inputs" : [" production" , " ^production" ]
87+ },
88+ "docker-build" : {
89+ "dependsOn" : [" build" ],
90+ "executor" : " nx:run-commands" ,
91+ "options" : {
92+ "command" : " docker build -f {projectRoot}/Dockerfile . -t {projectName}"
93+ }
94+ },
95+ "docker-run" : {
96+ "dependsOn" : [" docker-build" ],
97+ "executor" : " nx:run-commands" ,
98+ "options" : {
99+ "command" : [
100+ " docker run -it --rm --init" ,
101+ " -p $PORT:$PORT" ,
102+ " --env PORT" ,
103+ " {projectName}"
104+ ]
105+ }
87106 }
88107 },
89108 "release" : {
You can’t perform that action at this time.
0 commit comments