Skip to content

Commit 8417e36

Browse files
authored
Deploy v3 (#386)
* fix: copy needed highlight sources * chore: pnpm frozen lockfile * deploy: remove s3 proxy * upstream on everything * test
1 parent 48cfebb commit 8417e36

File tree

6 files changed

+48
-60
lines changed

6 files changed

+48
-60
lines changed

api/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,5 @@ FROM caddy:2-alpine AS app_caddy
105105
WORKDIR /srv/app
106106

107107
COPY --from=app_caddy_builder --link /usr/bin/caddy /usr/bin/caddy
108-
COPY --from=app_php --link /srv/app/public public/
108+
# COPY --from=app_php --link /srv/app/public public/
109109
COPY --link docker/caddy/Caddyfile /etc/caddy/Caddyfile

api/docker/caddy/Caddyfile

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -8,63 +8,10 @@
88
log {
99
output file /var/log/caddy/access.log
1010
}
11-
# Matches requests for HTML documents, for static files and for Next.js files,
12-
# except for known API paths and paths with extensions handled by API Platform
13-
14-
@pwa expression `path('/con/*','/con', '/fr/con/*', '/fr/con', '/en/con/*', '/en/con', '/favicon.ico', '/manifest.json', '/robots.txt', '/_next*', '/images*')`
15-
16-
@bucket_s3 expression `(
17-
path('/*')
18-
&& !path ('/con/*', '/con', '/fr/con/*', '/fr/con', '/en/con/*', '/en/con', '/favicon.ico', '/manifest.json', '/robots.txt', '/_next*', '/images/*')
19-
)`
20-
21-
@withoutExtension not path_regexp \.\w+$
22-
@withTld path_regexp \.(org|io|fr|com|pl|me|de|gg|dev)$
23-
@withTrailingSlash path_regexp ^(.*)/+$
2411

2512
route {
26-
root * /srv/app/public
27-
mercure {
28-
# Transport to use (default to Bolt)
29-
transport_url {$MERCURE_TRANSPORT_URL:bolt:///data/mercure.db}
30-
# Publisher JWT key
31-
publisher_jwt {env.MERCURE_PUBLISHER_JWT_KEY} {env.MERCURE_PUBLISHER_JWT_ALG}
32-
# Subscriber JWT key
33-
subscriber_jwt {env.MERCURE_SUBSCRIBER_JWT_KEY} {env.MERCURE_SUBSCRIBER_JWT_ALG}
34-
# Allow anonymous subscribers (double-check that it's what you want)
35-
anonymous
36-
# Enable the subscription API (double-check that it's what you want)
37-
subscriptions
38-
# Extra directives
39-
{$MERCURE_EXTRA_DIRECTIVES}
40-
}
41-
vulcain
42-
43-
# Add links to the API docs and to the Mercure Hub if not set explicitly (e.g. the PWA)
44-
header ?Link `</docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation", </.well-known/mercure>; rel="mercure"`
4513
# Disable Topics tracking if not enabled explicitly: https://github.com/jkarlin/topics
4614
header ?Permissions-Policy "browsing-topics=()"
47-
# Comment the following line if you don't want Next.js to catch requests for HTML documents.
48-
# In this case, they will be handled by the PHP app.
49-
50-
reverse_proxy @pwa http://{$PWA_UPSTREAM}
51-
52-
handle @bucket_s3 {
53-
54-
reverse_proxy {$BUCKET_S3_UPSTREAM} {
55-
header_up Host {http.reverse_proxy.upstream.hostport}
56-
}
57-
58-
# Handles DocumentIndices
59-
rewrite @withTld /{$BUCKET_S3_NAME}{path}/index.html
60-
rewrite @withTrailingSlash /{$BUCKET_S3_NAME}{path}index.html
61-
rewrite @withoutExtension /{$BUCKET_S3_NAME}{path}/index.html
62-
63-
# Everything else should be prefixed
64-
rewrite * /{$BUCKET_S3_NAME}{path}
65-
}
6615

67-
php_fastcgi unix//var/run/php/php-fpm.sock
68-
encode zstd gzip
69-
file_server
16+
reverse_proxy http://{$PWA_UPSTREAM}
7017
}

pwa/Dockerfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,15 @@ COPY pnpm-lock.yaml ./
2424
RUN pnpm fetch
2525

2626
COPY --link . .
27-
RUN pnpm install -r --offline
28-
27+
RUN pnpm install --offline --frozen-lock
2928

3029
# Development image
3130
FROM deps as dev
3231

3332
EXPOSE 3000
3433
ENV PORT 3000
3534

36-
CMD ["sh", "-c", "pnpm install -r --offline; pnpm dev"]
35+
CMD ["sh", "-c", "pnpm install --offline --frozen-lock; pnpm dev"]
3736

3837

3938
FROM builder_base AS builder
@@ -46,7 +45,8 @@ RUN --mount=type=secret,id=GITHUB_KEY \
4645
echo "Please set the GITHUB_KEY secret" && exit 1 ; \
4746
fi \
4847
&& pnpm run prebuild \
49-
&& pnpm run build
48+
&& pnpm run build \
49+
&& pnpm run postbuild
5050

5151
# Production image, copy all the files and run next
5252
FROM node:18-alpine AS prod
@@ -64,6 +64,7 @@ COPY --from=builder --link /srv/app/public ./public
6464
# Automatically leverage output traces to reduce image size
6565
# https://nextjs.org/docs/advanced-features/output-file-tracing
6666
COPY --from=builder --link --chown=nextjs:nodejs /srv/app/.next/standalone ./
67+
COPY --from=builder --link --chown=nextjs:nodejs /srv/app/public/* ./public/
6768
COPY --from=builder --link --chown=nextjs:nodejs /srv/app/.next/static ./.next/static
6869

6970
USER nextjs

pwa/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"start": "next start",
99
"lint": "next lint",
1010
"i18n": "ts-node ./update-i18n.ts; prettier ./i18n/dictionaries/*.json --write",
11-
"prebuild": "ts-node ./prebuild.ts"
11+
"prebuild": "ts-node ./prebuild.ts",
12+
"postbuild": "ts-node ./postbuild.ts"
1213
},
1314
"dependencies": {
1415
"@formatjs/intl-localematcher": "^0.2.32",
@@ -54,6 +55,7 @@
5455
"@types/sharp": "^0.31.1",
5556
"@typescript-eslint/eslint-plugin": "^5.59.9",
5657
"autoprefixer": "^10.4.14",
58+
"cpr": "^3.0.1",
5759
"encoding": "^0.1.13",
5860
"eslint": "^8.42.0",
5961
"eslint-config-next": "^13.4.4",

pwa/pnpm-lock.yaml

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pwa/postbuild.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const cpr = require("cpr");
2+
const path = require("path");
3+
4+
cpr(path.join(__dirname, 'node_modules/shiki/themes'), path.join(__dirname, '.next/standalone/node_modules/shiki/themes'), function(err: any, files: any) {
5+
err && console.error(err)
6+
});
7+
8+
cpr(path.join(__dirname, 'node_modules/shiki/languages'), path.join(__dirname, '.next/standalone/node_modules/shiki/languages'), function(err: any, files: any) {
9+
err && console.error(err)
10+
});
11+

0 commit comments

Comments
 (0)