diff --git a/.github/workflows/build_push_docker_latest.yml b/.github/workflows/build_push_docker_latest.yml index 94498af0ec..98a6821037 100644 --- a/.github/workflows/build_push_docker_latest.yml +++ b/.github/workflows/build_push_docker_latest.yml @@ -33,6 +33,8 @@ jobs: file: ./server/Dockerfile platforms: linux/arm/v7,linux/amd64,linux/arm64 push: true + cache-from: type=gha + cache-to: type=gha,mode=max tags: | altran1502/immich-server:latest @@ -61,6 +63,8 @@ jobs: file: ./machine-learning/Dockerfile platforms: linux/arm/v7,linux/amd64,linux/arm64 push: true + cache-from: type=gha + cache-to: type=gha,mode=max tags: | altran1502/immich-machine-learning:latest diff --git a/.github/workflows/build_push_docker_staging.yml b/.github/workflows/build_push_docker_staging.yml index 24c8033292..08e82e6230 100644 --- a/.github/workflows/build_push_docker_staging.yml +++ b/.github/workflows/build_push_docker_staging.yml @@ -34,6 +34,8 @@ jobs: file: ./server/Dockerfile platforms: linux/arm/v7,linux/amd64,linux/arm64 push: ${{ github.event_name == 'pull_request' && github.repository == 'immich-app/immich' }} + cache-from: type=gha + cache-to: type=gha,mode=max tags: | altran1502/immich-server:staging altran1502/immich-server:${{ github.event.pull_request.number }} @@ -64,6 +66,8 @@ jobs: file: ./machine-learning/Dockerfile platforms: linux/arm/v7,linux/amd64,linux/arm64 push: ${{ github.event_name == 'pull_request' && github.repository == 'immich-app/immich' }} + cache-from: type=gha + cache-to: type=gha,mode=max tags: | altran1502/immich-machine-learning:staging altran1502/immich-machine-learning:${{ github.event.pull_request.number }} diff --git a/.github/workflows/build_push_server_release.yml b/.github/workflows/build_push_server_release.yml index 7668c82639..30ffadab02 100644 --- a/.github/workflows/build_push_server_release.yml +++ b/.github/workflows/build_push_server_release.yml @@ -12,12 +12,12 @@ jobs: - name: Checkout uses: actions/checkout@v3 with: - ref: "main" + ref: 'main' fetch-depth: 0 - - name: "Get Previous tag" + - name: 'Get Previous tag' id: previoustag - uses: "WyriHaximus/github-action-get-previous-tag@v1" + uses: 'WyriHaximus/github-action-get-previous-tag@v1' with: fallback: latest @@ -41,6 +41,8 @@ jobs: file: ./server/Dockerfile platforms: linux/arm/v7,linux/amd64,linux/arm64 push: ${{ github.event_name != 'pull_request' }} + cache-from: type=gha + cache-to: type=gha,mode=max tags: | altran1502/immich-server:${{ steps.previoustag.outputs.tag }} altran1502/immich-server:release @@ -52,9 +54,9 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 - - name: "Get Previous tag" + - name: 'Get Previous tag' id: previoustag - uses: "WyriHaximus/github-action-get-previous-tag@v1" + uses: 'WyriHaximus/github-action-get-previous-tag@v1' with: fallback: latest - name: Set up QEMU @@ -74,6 +76,8 @@ jobs: file: ./machine-learning/Dockerfile platforms: linux/arm/v7,linux/amd64,linux/arm64 push: true + cache-from: type=gha + cache-to: type=gha,mode=max tags: | altran1502/immich-machine-learning:${{ steps.previoustag.outputs.tag }} altran1502/immich-machine-learning:release @@ -84,12 +88,12 @@ jobs: - name: Checkout uses: actions/checkout@v3 with: - ref: "main" + ref: 'main' fetch-depth: 0 - - name: "Get Previous tag" + - name: 'Get Previous tag' id: previoustag - uses: "WyriHaximus/github-action-get-previous-tag@v1" + uses: 'WyriHaximus/github-action-get-previous-tag@v1' with: fallback: latest @@ -124,12 +128,12 @@ jobs: - name: Checkout uses: actions/checkout@v3 with: - ref: "main" + ref: 'main' fetch-depth: 0 - - name: "Get Previous tag" + - name: 'Get Previous tag' id: previoustag - uses: "WyriHaximus/github-action-get-previous-tag@v1" + uses: 'WyriHaximus/github-action-get-previous-tag@v1' with: fallback: latest diff --git a/docker/docker-compose.test.yml b/docker/docker-compose.test.yml index 03220f04e6..8b4c8fe23f 100644 --- a/docker/docker-compose.test.yml +++ b/docker/docker-compose.test.yml @@ -1,4 +1,4 @@ -version: "3.8" +version: '3.8' services: immich-server-test: @@ -7,9 +7,9 @@ services: context: ../server dockerfile: Dockerfile target: builder - command: npm run test:e2e + command: npm ci && npm run test:e2e expose: - - "3000" + - '3000' volumes: - ../server:/usr/src/app - /usr/src/app/node_modules diff --git a/machine-learning/Dockerfile b/machine-learning/Dockerfile index b19813c234..f10ccd0c13 100644 --- a/machine-learning/Dockerfile +++ b/machine-learning/Dockerfile @@ -6,18 +6,18 @@ ARG DEBIAN_FRONTEND=noninteractive WORKDIR /usr/src/app -COPY package.json package-lock.json ./ - RUN apt-get update RUN apt-get install gcc g++ make cmake python3 python3-pip ffmpeg -y +COPY package.json package-lock.json ./ + RUN npm ci RUN npm rebuild @tensorflow/tfjs-node --build-from-source COPY . . RUN npm run build - +RUN npm prune --omit=dev # Prod stage FROM node:16-bullseye-slim @@ -26,18 +26,14 @@ ARG DEBIAN_FRONTEND=noninteractive WORKDIR /usr/src/app -COPY package.json package-lock.json ./ -COPY entrypoint.sh ./ - -RUN mkdir -p /usr/src/app/dist \ - && mkdir -p /usr/src/app/node_modules \ - && apt-get update \ +RUN apt-get update \ && apt-get install -y ffmpeg \ && rm -rf /var/cache/apt/lists COPY --from=builder /usr/src/app/node_modules ./node_modules COPY --from=builder /usr/src/app/dist ./dist -RUN npm prune --production +COPY package.json package-lock.json ./ +COPY entrypoint.sh ./ -# CMD [ "node", "dist/main" ] \ No newline at end of file +# CMD [ "node", "dist/main" ] diff --git a/server/Dockerfile b/server/Dockerfile index f2d4440836..5c33b794a6 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -2,33 +2,32 @@ FROM node:16-alpine3.14 as builder WORKDIR /usr/src/app +RUN apk add --update-cache build-base python3 libheif vips-dev ffmpeg + COPY package.json package-lock.json ./ -RUN apk add --update-cache build-base python3 libheif vips-dev ffmpeg RUN npm ci COPY . . RUN npm run build +RUN npm prune --omit=dev # Prod stage FROM node:16-alpine3.14 WORKDIR /usr/src/app -COPY LICENSE /licenses/LICENSE.txt -COPY LICENSE /LICENSE -COPY package.json package-lock.json ./ -COPY start-server.sh start-microservices.sh ./ - -RUN mkdir -p /usr/src/app/dist \ - && apk add --no-cache libheif vips ffmpeg +RUN apk add --no-cache libheif vips ffmpeg COPY --from=builder /usr/src/app/node_modules ./node_modules COPY --from=builder /usr/src/app/dist ./dist COPY --from=builder /usr/src/app/bin ./bin -RUN npm prune --production +COPY LICENSE /licenses/LICENSE.txt +COPY LICENSE /LICENSE +COPY package.json package-lock.json ./ +COPY start-server.sh start-microservices.sh ./ VOLUME /usr/src/app/upload