diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d826de6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,32 @@ +# Dependencies +**/node_modules + +# Build outputs +**/dist +**/.output +**/.nuxt + +# Database data +dev/data/db + +# Git +**/.git + +# IDE +**/.idea +**/.vscode + +# Environment files +**/.env +**/.env.* + +# Logs +**/*.log +**/logs + +# Test coverage +**/coverage + +# OS files +.DS_Store +Thumbs.db diff --git a/.gitea/workflows/pipeline.yaml b/.gitea/workflows/pipeline.yaml index 97fee02..c419e9c 100644 --- a/.gitea/workflows/pipeline.yaml +++ b/.gitea/workflows/pipeline.yaml @@ -72,7 +72,8 @@ jobs: - name: Build and push frontend docker image uses: docker/build-push-action@v6 with: - context: ./frontend + context: . + file: ./frontend/Dockerfile push: true tags: | git.vhaudiquet.fr/vhaudiquet/lolstats-frontend:latest @@ -90,7 +91,8 @@ jobs: - name: Build and push match_collector docker image uses: docker/build-push-action@v6 with: - context: ./match_collector + context: . + file: ./match_collector/Dockerfile push: true tags: | git.vhaudiquet.fr/vhaudiquet/lolstats-match_collector:latest diff --git a/frontend/Dockerfile b/frontend/Dockerfile index b935d5c..f365b25 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -2,12 +2,23 @@ FROM node:current-alpine AS base WORKDIR /app FROM base AS build -COPY package*.json ./ + +# Copy and build dragon-item-parser first +COPY dragon-item-parser/package*.json ./dragon-item-parser/ +COPY dragon-item-parser/tsconfig.json ./dragon-item-parser/ +COPY dragon-item-parser/src ./dragon-item-parser/src +WORKDIR /app/dragon-item-parser +RUN npm install && npm run build + +# Build the frontend +WORKDIR /app +COPY frontend/package*.json ./frontend/ +WORKDIR /app/frontend RUN npm install -COPY . . +COPY frontend/. . RUN npm run build FROM base -COPY --from=build /app/.output /app/.output +COPY --from=build /app/frontend/.output /app/.output EXPOSE 3000 -CMD ["node", ".output/server/index.mjs"] \ No newline at end of file +CMD ["node", ".output/server/index.mjs"] diff --git a/match_collector/Dockerfile b/match_collector/Dockerfile index 9aeb870..25a1dc9 100644 --- a/match_collector/Dockerfile +++ b/match_collector/Dockerfile @@ -1,8 +1,28 @@ -FROM node:lts-alpine -RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app +# This Dockerfile should be built from the project root directory: +# docker build -f match_collector/Dockerfile -t buildpath-match_collector . + +FROM node:current-alpine AS build +RUN mkdir -p /home/node/app && chown -R node:node /home/node/app +WORKDIR /home/node/app + +# Copy and build dragon-item-parser first +COPY --chown=node:node dragon-item-parser/package*.json ./dragon-item-parser/ +COPY --chown=node:node dragon-item-parser/tsconfig.json ./dragon-item-parser/ +COPY --chown=node:node dragon-item-parser/src ./dragon-item-parser/src +WORKDIR /home/node/app/dragon-item-parser +RUN npm install && npm run build + +# Build match_collector +WORKDIR /home/node/app +COPY --chown=node:node match_collector/package*.json ./match_collector/ +WORKDIR /home/node/app/match_collector +RUN npm install +COPY --chown=node:node match_collector/. . + +FROM node:current-alpine +RUN mkdir -p /home/node/app && chown -R node:node /home/node/app WORKDIR /home/node/app USER node -COPY --chown=node:node package*.json ./ -RUN npm install -COPY --chown=node:node . . -CMD ["/bin/sh", "-c", "node --import=tsx src/index.ts; sleep 20h"] \ No newline at end of file +COPY --from=build --chown=node:node /home/node/app/match_collector/node_modules ./node_modules +COPY --from=build --chown=node:node /home/node/app/match_collector/. . +CMD ["/bin/sh", "-c", "node --import=tsx src/index.ts; sleep 20h"]