Optimisations
This commit is contained in:
parent
525dcb502b
commit
8bb3e17a3b
10
.dockerignore
Normal file
10
.dockerignore
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
.DS_Store
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
.astro
|
||||||
|
.vscode
|
||||||
|
.gitignore
|
||||||
|
COPYING
|
||||||
|
Dockerfile
|
||||||
|
README.md
|
||||||
|
.gitea
|
@ -63,13 +63,9 @@ jobs:
|
|||||||
|
|
||||||
- name: Login to registry
|
- 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 }}"
|
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
|
- name: Docker Compose the image
|
||||||
run: ssh ${{ vars.TARGET_USER }}@${{ vars.TARGET }} -o StrictHostKeyChecking=no "docker pull ${{ vars.REGISTRY }}/${{ env.IMAGE_NAME }}:main"
|
run: ssh ${{ vars.TARGET_USER }}@${{ vars.TARGET }} -o StrictHostKeyChecking=no "docker compose up -d"
|
||||||
- name: Logout from registry
|
- name: Logout from registry
|
||||||
run: ssh ${{ vars.TARGET_USER }}@${{ vars.TARGET }} -o StrictHostKeyChecking=no "docker logout ${{ vars.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
|
- name: Clean old images
|
||||||
run: ssh ${{ vars.TARGET_USER }}@${{ vars.TARGET }} -o StrictHostKeyChecking=no "docker image prune -a"
|
run: ssh ${{ vars.TARGET_USER }}@${{ vars.TARGET }} -o StrictHostKeyChecking=no "docker image prune -a"
|
||||||
|
36
Dockerfile
36
Dockerfile
@ -1,29 +1,25 @@
|
|||||||
FROM node:lts-slim AS build
|
FROM node:lts-slim AS base
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN corepack enable pnpm
|
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
|
RUN pnpm install
|
||||||
|
|
||||||
COPY public/ public
|
FROM build-deps AS build
|
||||||
COPY src/ src
|
COPY . .
|
||||||
COPY astro.config.mjs astro.config.mjs
|
RUN pnpm run build
|
||||||
COPY tailwind.config.mjs tailwind.config.mjs
|
|
||||||
COPY tsconfig.json tsconfig.json
|
|
||||||
COPY components.json components.json
|
|
||||||
RUN npm run build
|
|
||||||
|
|
||||||
FROM node:lts-slim
|
FROM base AS runtime
|
||||||
WORKDIR /app
|
COPY --from=prod-deps /app/node_modules ./node_modules
|
||||||
|
COPY --from=build /app/dist ./dist
|
||||||
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
|
|
||||||
|
|
||||||
|
ENV HOST=0.0.0.0
|
||||||
|
ENV PORT=4321
|
||||||
EXPOSE 4321
|
EXPOSE 4321
|
||||||
|
CMD node ./dist/server/entry.mjs
|
||||||
CMD ["npm", "run", "preview"]
|
|
Loading…
Reference in New Issue
Block a user