mirror of
https://github.com/diced/zipline.git
synced 2025-12-12 15:50:11 -08:00
feat: docker & github actions
This commit is contained in:
10
.dockerignore
Normal file
10
.dockerignore
Normal file
@@ -0,0 +1,10 @@
|
||||
.github
|
||||
.next
|
||||
.yarn/cache
|
||||
.yarn/install-state.gz
|
||||
build
|
||||
node_modules
|
||||
public
|
||||
uploads
|
||||
.env
|
||||
.eslintcache
|
||||
18
.github/workflows/build.yml
vendored
18
.github/workflows/build.yml
vendored
@@ -20,7 +20,7 @@ jobs:
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
|
||||
|
||||
- name: 'Restore dependency cache'
|
||||
id: cache-restore
|
||||
uses: actions/cache@v3
|
||||
@@ -31,17 +31,13 @@ jobs:
|
||||
key: ${{ runner.os }}-node${{ matrix.node }}-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-node${{ matrix.node }}-${{ hashFiles('**/yarn.lock') }}-
|
||||
|
||||
|
||||
|
||||
- name: Install dependencies
|
||||
if: steps.cache-restore.outputs.cache-hit != 'true'
|
||||
run: yarn install
|
||||
|
||||
- name: Build
|
||||
env:
|
||||
ZIPLINE_BUILD: 'true'
|
||||
run: yarn build
|
||||
|
||||
|
||||
|
||||
|
||||
- name: Build
|
||||
env:
|
||||
ZIPLINE_BUILD: 'true'
|
||||
NEXT_TELEMETRY_DISABLED: '1'
|
||||
run: yarn build
|
||||
|
||||
35
.github/workflows/docker.yml
vendored
Normal file
35
.github/workflows/docker.yml
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
name: 'Push Docker Images'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [v4]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
push:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Get commit sha
|
||||
id: sha
|
||||
run: |
|
||||
echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- uses: docker/setup-qemu-action@v2
|
||||
- uses: docker/setup-buildx-action@v2
|
||||
- uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- uses: docker/build-push-action@v4
|
||||
with:
|
||||
push: true
|
||||
platforms: linux/amd64
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
tags: |
|
||||
ghcr.io/diced/zipline:v4
|
||||
ghcr.io/diced/zipline:v4-${{ steps.sha.outputs.short_sha }}
|
||||
61
Dockerfile
Normal file
61
Dockerfile
Normal file
@@ -0,0 +1,61 @@
|
||||
# FROM ghcr.io/diced/prisma-binaries:4.10.x as prisma-binaries
|
||||
|
||||
FROM node:18-alpine3.16 as base
|
||||
|
||||
WORKDIR /zipline
|
||||
|
||||
# Prisma binaries
|
||||
# COPY --from=prisma /prisma-engines /prisma-engines
|
||||
# ENV PRISMA_QUERY_ENGINE_BINARY=/prisma-engines/query-engine \
|
||||
# PRISMA_MIGRATION_ENGINE_BINARY=/prisma-engines/migration-engine \
|
||||
# PRISMA_INTROSPECTION_ENGINE_BINARY=/prisma-engines/introspection-engine \
|
||||
# PRISMA_FMT_BINARY=/prisma-engines/prisma-fmt \
|
||||
# PRISMA_CLI_QUERY_ENGINE_TYPE=binary \
|
||||
# PRISMA_CLIENT_ENGINE_TYPE=binary \
|
||||
# ZIPLINE_BUILD=true \
|
||||
# NEXT_TELEMETRY_DISABLED=1 \
|
||||
# NODE_ENV=production
|
||||
|
||||
ENV NEXT_TELEMETRY_DISABLED=1 \
|
||||
NODE_ENV=production
|
||||
|
||||
# Copy the necessary files from the project
|
||||
COPY prisma ./prisma
|
||||
COPY .yarn ./.yarn
|
||||
COPY package.json ./
|
||||
COPY yarn.lock ./
|
||||
COPY .yarnrc.yml ./
|
||||
|
||||
# Install the dependencies
|
||||
RUN yarn install --immutable
|
||||
|
||||
FROM base as builder
|
||||
|
||||
COPY src ./src
|
||||
COPY next.config.js ./next.config.js
|
||||
COPY tsup.config.ts ./tsup.config.ts
|
||||
COPY tsconfig.json ./tsconfig.json
|
||||
COPY mimes.json ./mimes.json
|
||||
COPY code.json ./code.json
|
||||
COPY themes ./themes
|
||||
|
||||
# Run the build
|
||||
RUN ZIPLINE_BUILD=true yarn build
|
||||
|
||||
# Use Alpine Linux as the final image
|
||||
FROM base
|
||||
|
||||
COPY --from=builder /zipline/build ./build
|
||||
COPY --from=builder /zipline/.next ./.next
|
||||
|
||||
COPY --from=builder /zipline/mimes.json ./mimes.json
|
||||
COPY --from=builder /zipline/code.json ./code.json
|
||||
|
||||
# remove the ZIPLINE_BUILD env var
|
||||
RUN unset ZIPLINE_BUILD
|
||||
|
||||
# clean
|
||||
RUN yarn cache clean --all
|
||||
RUN rm -rf /tmp/* /root/*
|
||||
|
||||
CMD ["node", "--enable-source-maps", "build/server.js"]
|
||||
36
docker-compose.dev.yml
Normal file
36
docker-compose.dev.yml
Normal file
@@ -0,0 +1,36 @@
|
||||
version: '3'
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:15
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
- POSTGRES_DATABASE=postgres
|
||||
volumes:
|
||||
- pgdata:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ['CMD', 'pg_isready', '-U', 'postgres']
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
zipline:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- '3000:3000'
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
- DATABASE_URL=postgres://postgres:postgres@postgres/postgres
|
||||
depends_on:
|
||||
- postgres
|
||||
volumes:
|
||||
- './uploads:/zipline/uploads'
|
||||
- './public:/zipline/public'
|
||||
- './themes:/zipline/themes'
|
||||
|
||||
volumes:
|
||||
pgdata:
|
||||
Reference in New Issue
Block a user