ci: docker_tag=ext-0.1.3 build: standalone Next, caches BuildKit, dockerignore, docs+changelog
All checks were successful
build-and-push-ext / build_push (push) Successful in 1m49s
All checks were successful
build-and-push-ext / build_push (push) Successful in 1m49s
This commit is contained in:
parent
26c26d4fd8
commit
7a7312afd4
10
.dockerignore
Normal file
10
.dockerignore
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
.git
|
||||||
|
node_modules
|
||||||
|
.next
|
||||||
|
coverage
|
||||||
|
dist
|
||||||
|
.DS_Store
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
.env*
|
@ -7,3 +7,11 @@
|
|||||||
## v0.1.2
|
## v0.1.2
|
||||||
|
|
||||||
- LoginCallback (`index.tsx`) ajusté: suppression de la redirection spéciale `local.4nkweb.com` au profit d'un flux standard basé sur variables d'environnement.
|
- LoginCallback (`index.tsx`) ajusté: suppression de la redirection spéciale `local.4nkweb.com` au profit d'un flux standard basé sur variables d'environnement.
|
||||||
|
|
||||||
|
## v0.1.3
|
||||||
|
|
||||||
|
- Optimisations build Docker:
|
||||||
|
- `.dockerignore` pour réduire le contexte.
|
||||||
|
- Next.js `output: 'standalone'` pour une image runtime plus légère.
|
||||||
|
- Caches BuildKit (npm et .next) pour accélérer les builds.
|
||||||
|
- Runtime basé sur `server.js` (standalone) au lieu de `next start`.
|
||||||
|
12
Dockerfile
12
Dockerfile
@ -9,6 +9,7 @@ RUN apk update && apk add --no-cache openssh-client git
|
|||||||
|
|
||||||
# Forward SSH agent via BuildKit (clé jamais écrite dans l'image)
|
# Forward SSH agent via BuildKit (clé jamais écrite dans l'image)
|
||||||
RUN --mount=type=ssh \
|
RUN --mount=type=ssh \
|
||||||
|
--mount=type=cache,target=/root/.npm \
|
||||||
mkdir -p /root/.ssh && \
|
mkdir -p /root/.ssh && \
|
||||||
ssh-keyscan git.4nkweb.com >> /root/.ssh/known_hosts && \
|
ssh-keyscan git.4nkweb.com >> /root/.ssh/known_hosts && \
|
||||||
npm install --no-audit --no-fund
|
npm install --no-audit --no-fund
|
||||||
@ -74,7 +75,7 @@ ENV NEXT_PUBLIC_BACK_API_PROTOCOL=${NEXT_PUBLIC_BACK_API_PROTOCOL} \
|
|||||||
NEXT_PUBLIC_DEFAULT_VALIDATOR_ID=${NEXT_PUBLIC_DEFAULT_VALIDATOR_ID} \
|
NEXT_PUBLIC_DEFAULT_VALIDATOR_ID=${NEXT_PUBLIC_DEFAULT_VALIDATOR_ID} \
|
||||||
NEXT_PUBLIC_DEFAULT_STORAGE_URLS=${NEXT_PUBLIC_DEFAULT_STORAGE_URLS}
|
NEXT_PUBLIC_DEFAULT_STORAGE_URLS=${NEXT_PUBLIC_DEFAULT_STORAGE_URLS}
|
||||||
|
|
||||||
RUN npm run build
|
RUN --mount=type=cache,target=/leCoffre-front/.next/cache npm run build
|
||||||
|
|
||||||
# --- Image d'exécution "ext"
|
# --- Image d'exécution "ext"
|
||||||
FROM node:19-alpine AS ext
|
FROM node:19-alpine AS ext
|
||||||
@ -83,15 +84,14 @@ WORKDIR /leCoffre-front
|
|||||||
ENV NODE_ENV=production \
|
ENV NODE_ENV=production \
|
||||||
PORT=3000
|
PORT=3000
|
||||||
|
|
||||||
COPY --from=builder /leCoffre-front/.next ./.next
|
# Next.js standalone runtime (output: 'standalone')
|
||||||
|
COPY --from=builder /leCoffre-front/.next/standalone ./
|
||||||
|
COPY --from=builder /leCoffre-front/.next/static ./.next/static
|
||||||
COPY --from=builder /leCoffre-front/public ./public
|
COPY --from=builder /leCoffre-front/public ./public
|
||||||
COPY --from=deps /leCoffre-front/node_modules ./node_modules
|
|
||||||
COPY --from=builder /leCoffre-front/package.json ./package.json
|
|
||||||
COPY --from=builder /leCoffre-front/next.config.js ./next.config.js
|
|
||||||
|
|
||||||
# Création de l'utilisateur non-root
|
# Création de l'utilisateur non-root
|
||||||
RUN adduser -D lecoffreuser --uid 10000 && chown -R lecoffreuser .
|
RUN adduser -D lecoffreuser --uid 10000 && chown -R lecoffreuser .
|
||||||
USER lecoffreuser
|
USER lecoffreuser
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
CMD ["npm", "run", "start"]
|
CMD ["node", "server.js"]
|
@ -33,7 +33,7 @@ Prérequis: Docker BuildKit activé et agent SSH opérationnel pour cloner `le-c
|
|||||||
|
|
||||||
1. `cd /home/debian/lecoffre-front`
|
1. `cd /home/debian/lecoffre-front`
|
||||||
2. `export DOCKER_BUILDKIT=1`
|
2. `export DOCKER_BUILDKIT=1`
|
||||||
3. `docker build --target ext --ssh default -t lecoffre/front:ext-0.1.2 -f /home/debian/lecoffre-front/Dockerfile /home/debian/lecoffre-front`
|
3. `docker build --target ext --ssh default -t lecoffre/front:ext-0.1.3 -f /home/debian/lecoffre-front/Dockerfile /home/debian/lecoffre-front`
|
||||||
|
|
||||||
#### Exécution locale (validation)
|
#### Exécution locale (validation)
|
||||||
|
|
||||||
@ -48,11 +48,11 @@ docker run --rm -p 3000:3000 \
|
|||||||
-e NEXT_PUBLIC_BACK_API_VERSION=v1 \
|
-e NEXT_PUBLIC_BACK_API_VERSION=v1 \
|
||||||
-e NEXT_PUBLIC_FRONT_APP_HOST=https://app.example.com \
|
-e NEXT_PUBLIC_FRONT_APP_HOST=https://app.example.com \
|
||||||
-e NEXT_PUBLIC_4NK_URL=https://app.example.com \
|
-e NEXT_PUBLIC_4NK_URL=https://app.example.com \
|
||||||
lecoffre/front:ext-0.1.2
|
lecoffre/front:ext-0.1.3
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Publication via CI (git.4nkweb.com)
|
#### Publication via CI (git.4nkweb.com)
|
||||||
|
|
||||||
- Le push d'image est effectué par la CI de `git.4nkweb.com` suite à un `git push`.
|
- Le push d'image est effectué par la CI de `git.4nkweb.com` suite à un `git push`.
|
||||||
- Définir le tag Docker dans le message de commit: `ci: docker_tag=ext-0.1.2` (fallback CI: `dev-test`).
|
- Définir le tag Docker dans le message de commit: `ci: docker_tag=ext-0.1.3` (fallback CI: `dev-test`).
|
||||||
- La branche peut être utilisée par la CI comme tag en l’absence d’override.
|
- La branche peut être utilisée par la CI comme tag en l’absence d’override.
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
reactStrictMode: false,
|
reactStrictMode: false,
|
||||||
|
output: 'standalone',
|
||||||
typescript: {
|
typescript: {
|
||||||
ignoreBuildErrors: true,
|
ignoreBuildErrors: true,
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "lecoffre-front",
|
"name": "lecoffre-front",
|
||||||
"version": "0.1.2",
|
"version": "0.1.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user