diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3c2fbc5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +# .dockerignore +/.drone.yml +/.nuxt +/.output +/docker +/node_modules +/.git* diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..d0152b0 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,51 @@ +--- +kind: pipeline +type: docker +name: testing + +steps: +- name: build + image: docker:dind + environment: + BASE_PATH: /${DRONE_REPO_OWNER}/${DRONE_REPO_NAME}/${DRONE_COMMIT_BRANCH}/ + COMPOSE_PROJECT_NAME: ${DRONE_REPO_OWNER,,}-${DRONE_REPO_NAME,,}-${DRONE_COMMIT_BRANCH//\//-} + SERVICE_3000_CHECK_HTTP: /${DRONE_REPO_OWNER}/${DRONE_REPO_NAME}/${DRONE_COMMIT_BRANCH}/ + SERVICE_3000_TAGS: urlprefix-testing.asycn.io/${DRONE_REPO_OWNER}/${DRONE_REPO_NAME}/${DRONE_COMMIT_BRANCH}/* + commands: + - docker compose -f docker/docker-compose.yml -f docker/docker-compose.labels.yml up --build -d + volumes: + - name: dockersock + path: /var/run/docker.sock + +- name: notify + image: appleboy/drone-telegram + when: + status: + - success + - failure + settings: + token: + from_secret: telegram_token + to: + from_secret: telegram_chat_id_ajr + format: markdown + message: > + {{#success build.status}} + ✅ `{{commit.email}}` a mis à jour la branche `{{commit.branch}}` sur le repo `{{repo.name}}`: + ``` + {{commit.message}} + ``` + 🌐 https://testing.asycn.io/${DRONE_REPO_OWNER}/${DRONE_REPO_NAME}/{{commit.branch}}/ + {{else}} + ❌ Le build #{{build.number}} du repo `{{repo.name}}` est un gros fail... + 📝 Commit de {{commit.email}} sur la branche `{{commit.branch}}`: + ``` + {{commit.message}} + ``` + 🌐 {{ build.link }} + {{/success}} + +volumes: +- name: dockersock + host: + path: /var/run/docker.sock diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..017744b --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,15 @@ +ARG NODE_VERSION=22 +FROM node:${NODE_VERSION}-alpine AS base +WORKDIR /app + +FROM base AS build +ENV BASE_PATH=/ +COPY package.json package-lock.json ./ +RUN npm install +COPY --link ./ ./ +RUN sed -i 's|"basePath": "/"|"basePath": "'${BASE_PATH:-/}'"|' config.json +RUN npm run build + +FROM build AS prod +ENV NODE_ENV=production +CMD ["npm", "run","serve"] diff --git a/docker/docker-compose.labels.yml b/docker/docker-compose.labels.yml new file mode 100644 index 0000000..6889e56 --- /dev/null +++ b/docker/docker-compose.labels.yml @@ -0,0 +1,8 @@ +version: "3" + +services: + radar: + labels: + - SERVICE_3000_CHECK_HTTP=${SERVICE_3000_CHECK_HTTP:-${BASE_PATH:-/}} + - SERVICE_3000_NAME=${SERVICE_3000_NAME:-${COMPOSE_PROJECT_NAME:-radar-3000}} + - SERVICE_3000_TAGS=${SERVICE_3000_TAGS:-urlprefix-radar.localhost/*} diff --git a/docker/docker-compose.local.yml b/docker/docker-compose.local.yml new file mode 100644 index 0000000..8a2b426 --- /dev/null +++ b/docker/docker-compose.local.yml @@ -0,0 +1,9 @@ +version: "3" + +services: + radar: + ports: + - 3000:3000 + volumes: + - ..:/app + diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..67ebfd9 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,12 @@ +version: "3" + +services: + radar: + build: + context: .. + dockerfile: docker/Dockerfile + environment: + NODE_ENV: ${NODE_ENV:-production} + ports: + - 3000 + restart: always