Optimisations
Some checks failed
Build Docker Image and Deploy / Build Image and push to Registry (push) Failing after 37s
Build Docker Image and Deploy / Deploy on webserver (push) Has been skipped

This commit is contained in:
Cyril Šebek 2024-07-07 22:49:39 +02:00
parent 525dcb502b
commit 8bb3e17a3b
Signed by: blboun3
SSH Key Fingerprint: SHA256:n9dMtOPzgsD+CCerUJslEnU2dzVanbaIv0XDQVRVjeg
3 changed files with 28 additions and 26 deletions

10
.dockerignore Normal file
View File

@ -0,0 +1,10 @@
.DS_Store
node_modules
dist
.astro
.vscode
.gitignore
COPYING
Dockerfile
README.md
.gitea

View File

@ -63,13 +63,9 @@ jobs:
- name: Login to registry
run: ssh ${{ vars.TARGET_USER }}@${{ vars.TARGET }} -o StrictHostKeyChecking=no "docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} ${{ vars.REGISTRY }}"
- name: Pull new image
run: ssh ${{ vars.TARGET_USER }}@${{ vars.TARGET }} -o StrictHostKeyChecking=no "docker pull ${{ vars.REGISTRY }}/${{ env.IMAGE_NAME }}:main"
- name: Docker Compose the image
run: ssh ${{ vars.TARGET_USER }}@${{ vars.TARGET }} -o StrictHostKeyChecking=no "docker compose up -d"
- name: Logout from registry
run: ssh ${{ vars.TARGET_USER }}@${{ vars.TARGET }} -o StrictHostKeyChecking=no "docker logout ${{ vars.REGISTRY }}"
- name: Stop and Remove the container
run: ssh ${{ vars.TARGET_USER }}@${{ vars.TARGET }} -o StrictHostKeyChecking=no "docker stop ${{ env.IMAGE_NAME }} && docker remove ${{ env.IMAGE_NAME }}"
- name: Recreate the container
run: ssh ${{ vars.TARGET_USER }}@${{ vars.TARGET }} -o StrictHostKeyChecking=no "docker run --name=${{ env.IMAGE_NAME }} ${{ env.IMAGE_NAME }}:main"
- name: Clean old images
run: ssh ${{ vars.TARGET_USER }}@${{ vars.TARGET }} -o StrictHostKeyChecking=no "docker image prune -a"

View File

@ -1,29 +1,25 @@
FROM node:lts-slim AS build
FROM node:lts-slim AS base
WORKDIR /app
RUN corepack enable pnpm
COPY package.json package.json
COPY package.json pnpm-lock.yaml ./
FROM base AS prod-deps
RUN pnpm install --omit=dev
FROM base AS build-deps
RUN pnpm install
COPY public/ public
COPY src/ src
COPY astro.config.mjs astro.config.mjs
COPY tailwind.config.mjs tailwind.config.mjs
COPY tsconfig.json tsconfig.json
COPY components.json components.json
RUN npm run build
FROM build-deps AS build
COPY . .
RUN pnpm run build
FROM node:lts-slim
WORKDIR /app
RUN corepack enable pnpm
COPY --from=build /app/dist /app/dist
COPY --from=build /app/package.json /app/package.json
COPY --from=build /app/pnpm-lock.yaml /app/pnpm-lock.yaml
RUN pnpm install --frozen-lockfile
FROM base AS runtime
COPY --from=prod-deps /app/node_modules ./node_modules
COPY --from=build /app/dist ./dist
ENV HOST=0.0.0.0
ENV PORT=4321
EXPOSE 4321
CMD ["npm", "run", "preview"]
CMD node ./dist/server/entry.mjs