From f276fdc6a0c2c7a69780d314e3a913bf2ef2d8e3 Mon Sep 17 00:00:00 2001 From: diced Date: Mon, 20 Jun 2022 22:29:33 -0700 Subject: [PATCH] feat(docker): remove arm docker stuff in favor of cross arch dockerfile --- .github/workflows/docker-arm.yml | 41 ---------------------------- .github/workflows/docker.yml | 3 ++- Dockerfile | 25 ++++++++--------- Dockerfile-arm | 46 -------------------------------- docker-compose.arm.yml | 46 -------------------------------- 5 files changed, 15 insertions(+), 146 deletions(-) delete mode 100644 .github/workflows/docker-arm.yml delete mode 100644 Dockerfile-arm delete mode 100644 docker-compose.arm.yml diff --git a/.github/workflows/docker-arm.yml b/.github/workflows/docker-arm.yml deleted file mode 100644 index f7b5ff1..0000000 --- a/.github/workflows/docker-arm.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: 'CD: Push ARM64 Docker Images' - -on: - push: - branches: [ trunk ] - paths: - - 'src/**' - - 'server/**' - - 'prisma/**' - - '.github/**' - workflow_dispatch: - -jobs: - push_to_ghcr: - name: Push Image to GitHub Packages - runs-on: ubuntu-latest - steps: - - name: Check out the repo - uses: actions/checkout@v2 - - - name: Setup QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to Github Packages - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build Docker Image - uses: docker/build-push-action@v2 - with: - file: ./Dockerfile-arm - platforms: linux/arm64 - push: true - tags: ghcr.io/diced/zipline/arm64:trunk \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e6ba8a3..e630345 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -8,6 +8,7 @@ on: - 'server/**' - 'prisma/**' - '.github/**' + - 'Dockerfile' workflow_dispatch: jobs: @@ -42,7 +43,7 @@ jobs: uses: docker/build-push-action@v2 with: push: true + platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm64/v8 tags: | ghcr.io/diced/zipline/zipline:trunk - ghcr.io/diced/zipline/amd64:trunk diced/zipline:trunk \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index bee7efc..4411397 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,17 @@ -FROM node:16-alpine AS deps +FROM frolvlad/alpine-glibc AS deps WORKDIR /build COPY .yarn .yarn COPY package.json yarn.lock .yarnrc.yml ./ -RUN apk add --no-cache libc6-compat +RUN apk add --no-cache libc6-compat nodejs yarn RUN yarn install --immutable -FROM node:16-alpine AS builder +FROM frolvlad/alpine-glibc AS builder WORKDIR /build +RUN apk add --no-cache nodejs yarn libc6-compat openssl openssl-dev + COPY --from=deps /build/node_modules ./node_modules COPY src ./src COPY scripts ./scripts @@ -20,20 +22,21 @@ COPY package.json yarn.lock .yarnrc.yml esbuild.config.js next.config.js next-en ENV ZIPLINE_DOCKER_BUILD 1 ENV NEXT_TELEMETRY_DISABLED 1 +RUN cat prisma/schema.prisma + RUN yarn build -FROM node:16-alpine AS runner +FROM frolvlad/alpine-glibc AS runner WORKDIR /zipline +RUN apk add --no-cache nodejs yarn libc6-compat openssl openssl-dev + ENV NODE_ENV production ENV NEXT_TELEMETRY_DISABLED 1 -RUN addgroup --system --gid 1001 zipline -RUN adduser --system --uid 1001 zipline - -COPY --from=builder --chown=zipline:zipline /build/.next ./.next -COPY --from=builder --chown=zipline:zipline /build/dist ./dist -COPY --from=builder --chown=zipline:zipline /build/node_modules ./node_modules +COPY --from=builder /build/.next ./.next +COPY --from=builder /build/dist ./dist +COPY --from=builder /build/node_modules ./node_modules COPY --from=builder /build/next.config.js ./next.config.js COPY --from=builder /build/src ./src @@ -42,6 +45,4 @@ COPY --from=builder /build/prisma ./prisma COPY --from=builder /build/tsconfig.json ./tsconfig.json COPY --from=builder /build/package.json ./package.json -USER zipline - CMD ["node", "dist/server"] \ No newline at end of file diff --git a/Dockerfile-arm b/Dockerfile-arm deleted file mode 100644 index 85bb8de..0000000 --- a/Dockerfile-arm +++ /dev/null @@ -1,46 +0,0 @@ -FROM node:16 AS deps -WORKDIR /build - -COPY .yarn .yarn -COPY package.json yarn.lock .yarnrc.yml ./ - -RUN yarn install --immutable - -FROM node:16 AS builder -WORKDIR /build - -COPY --from=deps /build/node_modules ./node_modules -COPY src ./src -COPY scripts ./scripts -COPY prisma ./prisma -COPY .yarn .yarn -COPY package.json yarn.lock .yarnrc.yml esbuild.config.js next.config.js next-env.d.ts zip-env.d.ts tsconfig.json ./ - -ENV ZIPLINE_DOCKER_BUILD 1 -ENV NEXT_TELEMETRY_DISABLED 1 - -RUN yarn build - -FROM node:16 AS runner -WORKDIR /zipline - -ENV NODE_ENV production -ENV NEXT_TELEMETRY_DISABLED 1 - -RUN addgroup --system --gid 1001 zipline -RUN adduser --system --uid 1001 zipline - -COPY --from=builder --chown=zipline:zipline /build/.next ./.next -COPY --from=builder --chown=zipline:zipline /build/dist ./dist -COPY --from=builder --chown=zipline:zipline /build/node_modules ./node_modules - -COPY --from=builder /build/next.config.js ./next.config.js -COPY --from=builder /build/src ./src -COPY --from=builder /build/scripts ./scripts -COPY --from=builder /build/prisma ./prisma -COPY --from=builder /build/tsconfig.json ./tsconfig.json -COPY --from=builder /build/package.json ./package.json - -USER zipline - -CMD ["node", "dist/server"] \ No newline at end of file diff --git a/docker-compose.arm.yml b/docker-compose.arm.yml deleted file mode 100644 index 8f042df..0000000 --- a/docker-compose.arm.yml +++ /dev/null @@ -1,46 +0,0 @@ -version: '3' -services: - postgres: - image: postgres - restart: always - environment: - - POSTGRES_USER=postgres - - POSTGRES_PASSWORD=postgres - - POSTGRES_DATABASE=postgres - volumes: - - pg_data:/var/lib/postgresql/data - healthcheck: - test: ['CMD-SHELL', 'pg_isready -U postgres'] - interval: 10s - timeout: 5s - retries: 5 - - zipline: - image: ghcr.io/diced/zipline/arm64:trunk - ports: - - '3000:3000' - restart: unless-stopped - environment: - - SECURE=false - - SECRET=changethis - - HOST=0.0.0.0 - - PORT=3000 - - DATASOURCE_TYPE=local - - DATASOURCE_LOCAL_DIRECTORY=./uploads - - DATABASE_URL=postgresql://postgres:postgres@postgres/postgres/ - - UPLOADER_ROUTE=/u - - UPLOADER_EMBED_ROUTE=/a - - UPLOADER_LENGTH=6 - - UPLOADER_ADMIN_LIMIT=104900000 - - UPLOADER_USER_LIMIT=104900000 - - UPLOADER_DISABLED_EXTS= - - URLS_ROUTE=/go - - URLS_LENGTH=6 - volumes: - - '$PWD/uploads:/zipline/uploads' - - '$PWD/public:/zipline/public' - depends_on: - - 'postgres' - -volumes: - pg_data: \ No newline at end of file