@jakubmazanec/carson-templates 2.1.0-unstable.f120647 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jakubmazanec/carson-templates",
3
- "version": "2.1.0-unstable.f120647",
3
+ "version": "2.1.0",
4
4
  "description": "Collection of Carson templates.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -6,7 +6,19 @@ strategy: overwrite
6
6
  let lines = [];
7
7
 
8
8
  for (let project of workspace.projects) {
9
- lines.push(`COPY --chown=nodeuser ${project.relativePath} ${project.relativePath}`);
9
+ if (project.config.deployment?.appName) {
10
+ lines.push(`COPY --from=build /workspace/${project.relativePath}/build /workspace/${project.relativePath}/build`);
11
+ lines.push(`COPY --from=build /workspace/${project.relativePath}/node_modules /workspace/${project.relativePath}/node_modules`);
12
+ lines.push(`COPY --from=build /workspace/${project.relativePath}/package.json /workspace/${project.relativePath}/package.json`);
13
+ } else {
14
+ if (project.packageJson.bin) {
15
+ lines.push(`COPY --from=build /workspace/${project.relativePath}/bin /workspace/${project.relativePath}/bin`);
16
+ }
17
+
18
+ lines.push(`COPY --from=build /workspace/${project.relativePath}/build /workspace/${project.relativePath}/build`);
19
+ lines.push(`COPY --from=build /workspace/${project.relativePath}/node_modules /workspace/${project.relativePath}/node_modules`);
20
+ lines.push(`COPY --from=build /workspace/${project.relativePath}/package.json /workspace/${project.relativePath}/package.json`);
21
+ }
10
22
  }
11
23
  -%>
12
24
  #
@@ -17,34 +29,41 @@ for (let project of workspace.projects) {
17
29
  # Run `npx carson update workspace` to regenerate.
18
30
  #
19
31
 
20
- FROM node:20-alpine
32
+ # Base stage
33
+ FROM node:20-slim as base
21
34
 
22
- # Create a new user and change directory ownership
23
- RUN adduser --disabled-password --home /app --uid 12000 --gecos '' nodeuser
24
- RUN chown -R nodeuser /app
25
- USER nodeuser
35
+ WORKDIR /workspace
26
36
 
27
- WORKDIR /app
37
+ ENV NODE_ENV=production
28
38
 
29
- # Copy files
30
- # We need to copy files needed for installing dependencies, app, and its direct and indirect dependencies that are located in the same workspace
31
- COPY --chown=nodeuser package.json package.json
32
- COPY --chown=nodeuser package-lock.json package-lock.json
33
- <%- lines.join('\n') %>
39
+ # Throw-away build stage to reduce size of final image
40
+ FROM base as build
41
+
42
+ # Install packages needed to install dependencies
43
+ RUN apt-get update -qq && \
44
+ apt-get install --no-install-recommends -y build-essential node-gyp pkg-config python-is-python3
34
45
 
35
46
  # Install dependencies
36
- RUN npm ci --omit dev --ignore-scripts
47
+ COPY --link package-lock.json package.json ./
48
+ RUN npm ci --include=dev --ignore-scripts
37
49
 
38
- # Delete .npmrc. It is needed for npm install, but contains token and we don't want to leave that in a docker image.
39
- RUN rm .npmrc
50
+ # Copy the workspace
51
+ COPY --link . .
40
52
 
41
- # Add stuff to process.env
42
- ENV IS_DOCKER=true
43
- ENV TZ=Europe/Prague
44
- ENV NODE_ENV=production
45
- ENV NODE_OPTIONS=--enable-source-maps
53
+ # Build
54
+ RUN npm run build
55
+
56
+ # Remove development dependencies
57
+ RUN npm prune --omit=dev
58
+
59
+ # Final stage for app image
60
+ FROM base
46
61
 
47
- WORKDIR /app/<%- project.relativePath %>
62
+ # Copy files
63
+ COPY --from=build /workspace/node_modules /workspace/node_modules
64
+ <%- lines.join('\n') %>
48
65
 
66
+ # Start the server
67
+ WORKDIR /workspace/apps/somewhere
49
68
  EXPOSE 5000
50
69
  ENTRYPOINT ["npm", "start"]
@@ -25,7 +25,6 @@ let developmentDependencies = [
25
25
  '@types/react-dom',
26
26
  '@vitest/coverage-v8',
27
27
  'autoprefixer',
28
- 'cross-env',
29
28
  'del-cli',
30
29
  'eslint',
31
30
  'happy-dom',
@@ -8,8 +8,14 @@ let lines = [];
8
8
 
9
9
  for (let project of workspace.projects) {
10
10
  if (project.config.deployment?.appName) {
11
- lines.push(`!${project.relativePath}/${BUILD_DIRECTORY}/**`);
11
+ lines.push(`!${project.relativePath}/app/**`);
12
+ lines.push(`!${project.relativePath}/public/**`);
13
+ lines.push(`!${project.relativePath}/env.d.ts`);
12
14
  lines.push(`!${project.relativePath}/package.json`);
15
+ lines.push(`!${project.relativePath}/postcss.config.cjs`);
16
+ lines.push(`!${project.relativePath}/tailwind.config.ts`);
17
+ lines.push(`!${project.relativePath}/tsconfig.json`);
18
+ lines.push(`!${project.relativePath}/vite.config.ts`);
13
19
 
14
20
  } else {
15
21
  if (project.packageJson.bin) {
@@ -23,6 +29,7 @@ for (let project of workspace.projects) {
23
29
 
24
30
  lines.push('!/package-lock.json');
25
31
  lines.push('!/package.json');
32
+ lines.push('!/turbo.json');
26
33
  -%>
27
34
  #
28
35
  # DO NOT EDIT!
@@ -40,5 +47,5 @@ lines.push('!/package.json');
40
47
  # except files that are allowed to be in the Docker image
41
48
  <%- lines.join('\n') %>
42
49
 
43
- # we also need .npmrc with token; don't worry, it's deleted during Docker image creation
50
+ # we might also need .npmrc with token
44
51
  !.npmrc
@@ -104,6 +104,13 @@ jobs:
104
104
  NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
105
105
  NPM_CONFIG_PROVENANCE: 'true' # must be string, not boolean
106
106
  <%
107
+ if (workspace.projects.some((project) => project.config.deployment?.appName)) {
108
+ -%>
109
+
110
+ - uses: superfly/flyctl-actions/setup-flyctl@master
111
+ <%
112
+ }
113
+
107
114
  for (let project of workspace.projects) {
108
115
  if (project.config.deployment?.appName) {
109
116
  -%>
@@ -112,7 +119,8 @@ for (let project of workspace.projects) {
112
119
  run:
113
120
  npm run deploy --workspace <%- project.name %> -- --app <%- project.config.deployment?.appName %>-unstable
114
121
  env:
115
- FLY_TOKEN: ${{ secrets.FLY_TOKEN }}
122
+ FLY_ACCESS_TOKEN: ${{ secrets.FLY_TOKEN }}
123
+ FLY_API_TOKEN: ${{ secrets.FLY_TOKEN }}
116
124
  <%
117
125
  }
118
126
  }
@@ -123,6 +123,13 @@ jobs:
123
123
  run: |
124
124
  git push --follow-tags
125
125
  <%
126
+ if (workspace.projects.some((project) => project.config.deployment?.appName)) {
127
+ -%>
128
+
129
+ - uses: superfly/flyctl-actions/setup-flyctl@master
130
+ <%
131
+ }
132
+
126
133
  for (let project of workspace.projects) {
127
134
  if (project.config.deployment?.appName) {
128
135
  -%>
@@ -131,7 +138,8 @@ for (let project of workspace.projects) {
131
138
  run:
132
139
  npm run deploy --workspace <%- project.name %>
133
140
  env:
134
- FLY_TOKEN: ${{ secrets.FLY_TOKEN }}
141
+ FLY_ACCESS_TOKEN: ${{ secrets.FLY_TOKEN }}
142
+ FLY_API_TOKEN: ${{ secrets.FLY_TOKEN }}
135
143
  <%
136
144
  }
137
145
  }
@@ -248,6 +256,13 @@ for (let project of workspace.projects) {
248
256
  NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
249
257
  NPM_CONFIG_PROVENANCE: 'true' # must be string, not boolean
250
258
  <%
259
+ if (workspace.projects.some((project) => project.config.deployment?.appName)) {
260
+ -%>
261
+
262
+ - uses: superfly/flyctl-actions/setup-flyctl@master
263
+ <%
264
+ }
265
+
251
266
  for (let project of workspace.projects) {
252
267
  if (project.config.deployment?.appName) {
253
268
  -%>
@@ -256,7 +271,8 @@ for (let project of workspace.projects) {
256
271
  run:
257
272
  npm run deploy --workspace <%- project.name %> -- --app <%- project.config.deployment?.appName %>-next
258
273
  env:
259
- FLY_TOKEN: ${{ secrets.FLY_TOKEN }}
274
+ FLY_ACCESS_TOKEN: ${{ secrets.FLY_TOKEN }}
275
+ FLY_API_TOKEN: ${{ secrets.FLY_TOKEN }}
260
276
  <%
261
277
  }
262
278
  }
@@ -254,4 +254,5 @@ web_modules/
254
254
  # Project specific files
255
255
 
256
256
  ## Build folders
257
+ apps/**/<%- BUILD_DIRECTORY %>
257
258
  packages/**/<%- BUILD_DIRECTORY %>