build(server): use github-action cache (#949)
* build(server): prune dependencies in docker builder * fix: e2e tests * refactor: dockerfile step order * fix: vips build dependency * feat: use caching
This commit is contained in:
parent
b457bfbd4e
commit
cc61729f01
6 changed files with 41 additions and 34 deletions
|
@ -33,6 +33,8 @@ jobs:
|
||||||
file: ./server/Dockerfile
|
file: ./server/Dockerfile
|
||||||
platforms: linux/arm/v7,linux/amd64,linux/arm64
|
platforms: linux/arm/v7,linux/amd64,linux/arm64
|
||||||
push: true
|
push: true
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
tags: |
|
tags: |
|
||||||
altran1502/immich-server:latest
|
altran1502/immich-server:latest
|
||||||
|
|
||||||
|
@ -61,6 +63,8 @@ jobs:
|
||||||
file: ./machine-learning/Dockerfile
|
file: ./machine-learning/Dockerfile
|
||||||
platforms: linux/arm/v7,linux/amd64,linux/arm64
|
platforms: linux/arm/v7,linux/amd64,linux/arm64
|
||||||
push: true
|
push: true
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
tags: |
|
tags: |
|
||||||
altran1502/immich-machine-learning:latest
|
altran1502/immich-machine-learning:latest
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,8 @@ jobs:
|
||||||
file: ./server/Dockerfile
|
file: ./server/Dockerfile
|
||||||
platforms: linux/arm/v7,linux/amd64,linux/arm64
|
platforms: linux/arm/v7,linux/amd64,linux/arm64
|
||||||
push: ${{ github.event_name == 'pull_request' && github.repository == 'immich-app/immich' }}
|
push: ${{ github.event_name == 'pull_request' && github.repository == 'immich-app/immich' }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
tags: |
|
tags: |
|
||||||
altran1502/immich-server:staging
|
altran1502/immich-server:staging
|
||||||
altran1502/immich-server:${{ github.event.pull_request.number }}
|
altran1502/immich-server:${{ github.event.pull_request.number }}
|
||||||
|
@ -64,6 +66,8 @@ jobs:
|
||||||
file: ./machine-learning/Dockerfile
|
file: ./machine-learning/Dockerfile
|
||||||
platforms: linux/arm/v7,linux/amd64,linux/arm64
|
platforms: linux/arm/v7,linux/amd64,linux/arm64
|
||||||
push: ${{ github.event_name == 'pull_request' && github.repository == 'immich-app/immich' }}
|
push: ${{ github.event_name == 'pull_request' && github.repository == 'immich-app/immich' }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
tags: |
|
tags: |
|
||||||
altran1502/immich-machine-learning:staging
|
altran1502/immich-machine-learning:staging
|
||||||
altran1502/immich-machine-learning:${{ github.event.pull_request.number }}
|
altran1502/immich-machine-learning:${{ github.event.pull_request.number }}
|
||||||
|
|
26
.github/workflows/build_push_server_release.yml
vendored
26
.github/workflows/build_push_server_release.yml
vendored
|
@ -12,12 +12,12 @@ jobs:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
ref: "main"
|
ref: 'main'
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: "Get Previous tag"
|
- name: 'Get Previous tag'
|
||||||
id: previoustag
|
id: previoustag
|
||||||
uses: "WyriHaximus/github-action-get-previous-tag@v1"
|
uses: 'WyriHaximus/github-action-get-previous-tag@v1'
|
||||||
with:
|
with:
|
||||||
fallback: latest
|
fallback: latest
|
||||||
|
|
||||||
|
@ -41,6 +41,8 @@ jobs:
|
||||||
file: ./server/Dockerfile
|
file: ./server/Dockerfile
|
||||||
platforms: linux/arm/v7,linux/amd64,linux/arm64
|
platforms: linux/arm/v7,linux/amd64,linux/arm64
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
tags: |
|
tags: |
|
||||||
altran1502/immich-server:${{ steps.previoustag.outputs.tag }}
|
altran1502/immich-server:${{ steps.previoustag.outputs.tag }}
|
||||||
altran1502/immich-server:release
|
altran1502/immich-server:release
|
||||||
|
@ -52,9 +54,9 @@ jobs:
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: "Get Previous tag"
|
- name: 'Get Previous tag'
|
||||||
id: previoustag
|
id: previoustag
|
||||||
uses: "WyriHaximus/github-action-get-previous-tag@v1"
|
uses: 'WyriHaximus/github-action-get-previous-tag@v1'
|
||||||
with:
|
with:
|
||||||
fallback: latest
|
fallback: latest
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
|
@ -74,6 +76,8 @@ jobs:
|
||||||
file: ./machine-learning/Dockerfile
|
file: ./machine-learning/Dockerfile
|
||||||
platforms: linux/arm/v7,linux/amd64,linux/arm64
|
platforms: linux/arm/v7,linux/amd64,linux/arm64
|
||||||
push: true
|
push: true
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
tags: |
|
tags: |
|
||||||
altran1502/immich-machine-learning:${{ steps.previoustag.outputs.tag }}
|
altran1502/immich-machine-learning:${{ steps.previoustag.outputs.tag }}
|
||||||
altran1502/immich-machine-learning:release
|
altran1502/immich-machine-learning:release
|
||||||
|
@ -84,12 +88,12 @@ jobs:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
ref: "main"
|
ref: 'main'
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: "Get Previous tag"
|
- name: 'Get Previous tag'
|
||||||
id: previoustag
|
id: previoustag
|
||||||
uses: "WyriHaximus/github-action-get-previous-tag@v1"
|
uses: 'WyriHaximus/github-action-get-previous-tag@v1'
|
||||||
with:
|
with:
|
||||||
fallback: latest
|
fallback: latest
|
||||||
|
|
||||||
|
@ -124,12 +128,12 @@ jobs:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
ref: "main"
|
ref: 'main'
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: "Get Previous tag"
|
- name: 'Get Previous tag'
|
||||||
id: previoustag
|
id: previoustag
|
||||||
uses: "WyriHaximus/github-action-get-previous-tag@v1"
|
uses: 'WyriHaximus/github-action-get-previous-tag@v1'
|
||||||
with:
|
with:
|
||||||
fallback: latest
|
fallback: latest
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
version: "3.8"
|
version: '3.8'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
immich-server-test:
|
immich-server-test:
|
||||||
|
@ -7,9 +7,9 @@ services:
|
||||||
context: ../server
|
context: ../server
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
target: builder
|
target: builder
|
||||||
command: npm run test:e2e
|
command: npm ci && npm run test:e2e
|
||||||
expose:
|
expose:
|
||||||
- "3000"
|
- '3000'
|
||||||
volumes:
|
volumes:
|
||||||
- ../server:/usr/src/app
|
- ../server:/usr/src/app
|
||||||
- /usr/src/app/node_modules
|
- /usr/src/app/node_modules
|
||||||
|
|
|
@ -6,18 +6,18 @@ ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
COPY package.json package-lock.json ./
|
|
||||||
|
|
||||||
RUN apt-get update
|
RUN apt-get update
|
||||||
RUN apt-get install gcc g++ make cmake python3 python3-pip ffmpeg -y
|
RUN apt-get install gcc g++ make cmake python3 python3-pip ffmpeg -y
|
||||||
|
|
||||||
|
COPY package.json package-lock.json ./
|
||||||
|
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
RUN npm rebuild @tensorflow/tfjs-node --build-from-source
|
RUN npm rebuild @tensorflow/tfjs-node --build-from-source
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
RUN npm prune --omit=dev
|
||||||
|
|
||||||
# Prod stage
|
# Prod stage
|
||||||
FROM node:16-bullseye-slim
|
FROM node:16-bullseye-slim
|
||||||
|
@ -26,18 +26,14 @@ ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
COPY package.json package-lock.json ./
|
RUN apt-get update \
|
||||||
COPY entrypoint.sh ./
|
|
||||||
|
|
||||||
RUN mkdir -p /usr/src/app/dist \
|
|
||||||
&& mkdir -p /usr/src/app/node_modules \
|
|
||||||
&& apt-get update \
|
|
||||||
&& apt-get install -y ffmpeg \
|
&& apt-get install -y ffmpeg \
|
||||||
&& rm -rf /var/cache/apt/lists
|
&& rm -rf /var/cache/apt/lists
|
||||||
|
|
||||||
COPY --from=builder /usr/src/app/node_modules ./node_modules
|
COPY --from=builder /usr/src/app/node_modules ./node_modules
|
||||||
COPY --from=builder /usr/src/app/dist ./dist
|
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" ]
|
# CMD [ "node", "dist/main" ]
|
|
@ -2,33 +2,32 @@ FROM node:16-alpine3.14 as builder
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
RUN apk add --update-cache build-base python3 libheif vips-dev ffmpeg
|
||||||
|
|
||||||
COPY package.json package-lock.json ./
|
COPY package.json package-lock.json ./
|
||||||
|
|
||||||
RUN apk add --update-cache build-base python3 libheif vips-dev ffmpeg
|
|
||||||
RUN npm ci
|
RUN npm ci
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
RUN npm prune --omit=dev
|
||||||
|
|
||||||
# Prod stage
|
# Prod stage
|
||||||
FROM node:16-alpine3.14
|
FROM node:16-alpine3.14
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
COPY LICENSE /licenses/LICENSE.txt
|
|
||||||
COPY LICENSE /LICENSE
|
|
||||||
|
|
||||||
COPY package.json package-lock.json ./
|
RUN apk add --no-cache libheif vips ffmpeg
|
||||||
COPY start-server.sh start-microservices.sh ./
|
|
||||||
|
|
||||||
RUN mkdir -p /usr/src/app/dist \
|
|
||||||
&& apk add --no-cache libheif vips ffmpeg
|
|
||||||
|
|
||||||
COPY --from=builder /usr/src/app/node_modules ./node_modules
|
COPY --from=builder /usr/src/app/node_modules ./node_modules
|
||||||
COPY --from=builder /usr/src/app/dist ./dist
|
COPY --from=builder /usr/src/app/dist ./dist
|
||||||
COPY --from=builder /usr/src/app/bin ./bin
|
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
|
VOLUME /usr/src/app/upload
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue