@jakubmazanec/carson-templates 2.1.0-unstable.f876db2 → 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.f876db2",
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,31 +29,41 @@ for (let project of workspace.projects) {
17
29
  # Run `npx carson update workspace` to regenerate.
18
30
  #
19
31
 
20
- FROM node:16-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 --ignore-scripts
47
+ COPY --link package-lock.json package.json ./
48
+ RUN npm ci --include=dev --ignore-scripts
37
49
 
38
- # Add stuff to process.env
39
- ENV IS_DOCKER=true
40
- ENV TZ=Europe/Prague
41
- ENV NODE_ENV=production
42
- ENV NODE_OPTIONS=--enable-source-maps
50
+ # Copy the workspace
51
+ COPY --link . .
43
52
 
44
- WORKDIR /app/<%- project.relativePath %>
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
61
+
62
+ # Copy files
63
+ COPY --from=build /workspace/node_modules /workspace/node_modules
64
+ <%- lines.join('\n') %>
45
65
 
66
+ # Start the server
67
+ WORKDIR /workspace/apps/somewhere
46
68
  EXPOSE 5000
47
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',
@@ -0,0 +1,51 @@
1
+ ---
2
+ to: '.dockerignore'
3
+ if: <%- workspace.projects.some((project) => project.config.deployment?.appName) %>
4
+ strategy: overwrite
5
+ ---
6
+ <%
7
+ let lines = [];
8
+
9
+ for (let project of workspace.projects) {
10
+ if (project.config.deployment?.appName) {
11
+ lines.push(`!${project.relativePath}/app/**`);
12
+ lines.push(`!${project.relativePath}/public/**`);
13
+ lines.push(`!${project.relativePath}/env.d.ts`);
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`);
19
+
20
+ } else {
21
+ if (project.packageJson.bin) {
22
+ lines.push(`!${project.relativePath}/bin/**`);
23
+ }
24
+
25
+ lines.push(`!${project.relativePath}/${BUILD_DIRECTORY}/**`);
26
+ lines.push(`!${project.relativePath}/package.json`);
27
+ }
28
+ }
29
+
30
+ lines.push('!/package-lock.json');
31
+ lines.push('!/package.json');
32
+ lines.push('!/turbo.json');
33
+ -%>
34
+ #
35
+ # DO NOT EDIT!
36
+ # This file was autogenerated by Carson.
37
+ # Changes may cause incorrect behavior and will be lost when the file is regenerated.
38
+ #
39
+ # Run `npx carson update workspace` to regenerate.
40
+ #
41
+
42
+ # TODO: Use wildcards instead of package names when this is fixed: https://github.com/moby/moby/issues/40319
43
+
44
+ # ignore everything
45
+ *
46
+
47
+ # except files that are allowed to be in the Docker image
48
+ <%- lines.join('\n') %>
49
+
50
+ # we might also need .npmrc with token
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 %>