Skip to content

Commit

Permalink
wip [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-rutkowski committed Oct 4, 2023
1 parent 1b4973c commit 49f3251
Showing 1 changed file with 56 additions and 21 deletions.
77 changes: 56 additions & 21 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -198,71 +198,103 @@ business-parse:
SAVE ARTIFACT /content AS LOCAL ./data_layer/content
SAVE ARTIFACT /content AS LOCAL ./business/tests/data/dl_content

client-deps:

node-fr: ## couche de build pour les images node
ARG TARGETPLATFORM
FROM --platform=$TARGETPLATFORM node:20
ARG APP_DIR="./app.territoiresentransitions.react"
ARG PLATFORM=$TARGETPLATFORM
FROM --platform=$PLATFORM node:20
ENV LANG fr_FR.UTF-8
RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* && locale-gen "fr_FR.UTF-8"
WORKDIR "/app"
SAVE IMAGE node-fr:latest_$PLATFORM

node-fr-deps: ## couche de build pour les modules front
ARG --required APP_DIR
FROM +node-fr
# dépendances globales
COPY ./package.json ./
COPY ./package-lock.json ./
# dépendances du module
COPY $APP_DIR/package.json ./$APP_DIR/
# dépendances du module partagé
COPY ./packages/ui/package.json ./packages/ui/
# installe les dépendances
RUN npm ci -ws --if-present
# copie les sources des modules à construire
COPY $APP_DIR/. ./$APP_DIR/
COPY ./packages/ui ./packages/ui
SAVE IMAGE node-fr-deps:latest_$PLATFORM

client-build:
FROM +client-deps
app-deps: ## dépendances pour l'app
FROM +node-fr-deps --APP_DIR="./app.territoiresentransitions.react"
SAVE IMAGE app-deps:latest_$PLATFORM

app-build: ## build l'app
ARG PLATFORM
ARG --required ANON_KEY
ARG --required BROWSER_API_URL
ARG --required SERVER_API_URL
ARG APP_DIR="./app.territoiresentransitions.react"
FROM +app-deps
ENV REACT_APP_SUPABASE_URL=$BROWSER_API_URL
ENV REACT_APP_SUPABASE_KEY=$ANON_KEY
ENV ZIP_ORIGIN_OVERRIDE=$SERVER_API_URL
RUN npm run build -w @tet/ui -w @tet/app
WORKDIR $APP_DIR
EXPOSE 3000
CMD npm start
SAVE IMAGE client:latest
CMD npm -w @tet/app start
SAVE IMAGE app:latest_$PLATFORM

client:
app-dev: ## build et lance l'app en local (dev only)
ARG --required ANON_KEY
ARG --required API_URL
ARG internal_url=http://supabase_kong_tet:8000
ARG network=supabase_network_tet
LOCALLY
RUN earthly +client-build --ANON_KEY=$ANON_KEY --BROWSER_API_URL=$API_URL --SERVER_API_URL=$internal_url
RUN earthly +app-build --ANON_KEY=$ANON_KEY --BROWSER_API_URL=$API_URL --SERVER_API_URL=$internal_url
RUN docker run -d --rm \
--name client_tet \
--network $network \
--publish 3000:3000 \
client:latest

client-test-build:
FROM +client-deps
app-test-build:
FROM +app-deps
ENV REACT_APP_SUPABASE_URL
ENV REACT_APP_SUPABASE_KEY
ENV ZIP_ORIGIN_OVERRIDE
ENV CI=true
CMD npm run test -w @tet/app
SAVE IMAGE client-test:latest
SAVE IMAGE app-test:latest

client-test:
app-test:
ARG --required ANON_KEY
ARG url=http://supabase_kong_tet:8000
ARG network=supabase_network_tet
LOCALLY
RUN earthly +client-test-build
RUN earthly +app-test-build
RUN docker run --rm \
--name client-test_tet \
--name app-test_tet \
--network $network \
--env REACT_APP_SUPABASE_URL=$url \
--env REACT_APP_SUPABASE_KEY=$ANON_KEY \
--env ZIP_ORIGIN_OVERRIDE=$url \
client-test:latest
app-test:latest

site-deps: ## dépendances pour le site
FROM +node-fr-deps --APP_DIR="./packages/site"

site-build: ## build le site
ARG PLATFORM
ARG --required ANON_KEY
ARG --required API_URL
ARG --required STRAPI_KEY
ARG --required STRAPI_URL
FROM +site-deps
ENV NEXT_PUBLIC_STRAPI_KEY=$STRAPI_KEY
ENV NEXT_PUBLIC_STRAPI_URL=$STRAPI_URL
ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=$ANON_KEY
ENV NEXT_PUBLIC_SUPABASE_URL=$API_URL
ENV NEXT_TELEMETRY_DISABLED=1
RUN npm run build -w @tet/ui -w @tet/site
SAVE IMAGE site:latest_$PLATFORM

curl-test-build:
FROM curlimages/curl:8.1.0
Expand Down Expand Up @@ -415,7 +447,7 @@ dev:
END

IF [ "$client" = "yes" ]
RUN earthly +client
RUN earthly +app-dev
END

RUN earthly +refresh-views
Expand Down Expand Up @@ -464,5 +496,8 @@ test:
RUN earthly +business-test
RUN earthly +api-test
RUN earthly +deploy-test
RUN earthly +client-test
RUN earthly +app-test

help: ## affiche ce message d'aide
LOCALLY
RUN grep -h "##" ./Earthfile | grep -v grep | sed -e 's/##//'

0 comments on commit 49f3251

Please sign in to comment.