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
|
||||
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"
|
||||
|
36
Dockerfile
36
Dockerfile
@ -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
|
Loading…
Reference in New Issue
Block a user