diff --git a/.gitea/workflows/build-and-deploy.yml b/.gitea/workflows/build-and-deploy.yml index a67c49d..d5b6742 100644 --- a/.gitea/workflows/build-and-deploy.yml +++ b/.gitea/workflows/build-and-deploy.yml @@ -19,9 +19,9 @@ jobs: username: nucleo000 password: 7bc7b2fcd283bd6a251bef3ede368b7f897c919d - - name: Build+push radiusnucleo + - name: Build+push radiusnucleo (with SPA) run: | - docker build -t $REG/radiusnucleo:${{ github.sha }} -t $REG/radiusnucleo:latest ./node-api + docker build -t $REG/radiusnucleo:${{ github.sha }} -t $REG/radiusnucleo:latest -f node-api/Dockerfile . docker push $REG/radiusnucleo:${{ github.sha }} docker push $REG/radiusnucleo:latest diff --git a/docker-compose.yml b/docker-compose.yml index fcde410..d156630 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,9 @@ version: "3.9" services: node: - build: ./node-api + build: + context: . + dockerfile: node-api/Dockerfile image: gitea.nucleoriofrio.com/nucleo000/radiusnucleo:latest environment: - VLAN_ID=2 diff --git a/node-api/Dockerfile b/node-api/Dockerfile index b077b84..e1571ee 100644 --- a/node-api/Dockerfile +++ b/node-api/Dockerfile @@ -1,11 +1,20 @@ +FROM node:20-alpine AS frontend +WORKDIR /frontend +COPY ../frontend/package*.json ./ +RUN npm ci || npm i +COPY ../frontend/ . +RUN npm run build + FROM node:20-alpine WORKDIR /app +ENV NODE_ENV=production COPY package*.json ./ RUN npm ci --only=production || npm i --only=production COPY . . +# Overwrite static with built SPA +COPY --from=frontend /frontend/dist /app/public EXPOSE 3000 CMD ["node", "index.js"] -