|
| 1 | +# Development stage |
| 2 | +FROM denoland/deno:alpine AS development |
| 3 | + |
| 4 | +# Install pgbadger dependencies |
| 5 | +RUN apk add --no-cache \ |
| 6 | + perl \ |
| 7 | + perl-text-csv-xs \ |
| 8 | + wget \ |
| 9 | + make \ |
| 10 | + git |
| 11 | + |
| 12 | +# Download, build, and install pgBadger |
| 13 | +ARG PGBADGER_VERSION=12.3 |
| 14 | +WORKDIR /tmp |
| 15 | +RUN wget https://github.com/darold/pgbadger/archive/v${PGBADGER_VERSION}.tar.gz && \ |
| 16 | + tar -xzf v${PGBADGER_VERSION}.tar.gz && \ |
| 17 | + cd pgbadger-${PGBADGER_VERSION} && \ |
| 18 | + perl Makefile.PL && \ |
| 19 | + make && \ |
| 20 | + make install && \ |
| 21 | + rm -rf /tmp/pgbadger* |
| 22 | + |
| 23 | +# Set working directory |
| 24 | +WORKDIR /app |
| 25 | + |
| 26 | +# Copy dependency files |
| 27 | +COPY deno.json deno.lock* ./ |
| 28 | + |
| 29 | +# Cache dependencies |
| 30 | +RUN deno cache main.ts |
| 31 | + |
| 32 | +# Copy source code |
| 33 | +COPY . . |
| 34 | + |
| 35 | +# Expose port for development server (if needed) |
| 36 | +EXPOSE 8000 |
| 37 | + |
| 38 | +# Development command with hot reload |
| 39 | +CMD ["deno", "task", "dev"] |
| 40 | + |
| 41 | +# Production stage |
| 42 | +FROM denoland/deno:alpine AS production |
| 43 | + |
| 44 | +# Install pgbadger dependencies |
| 45 | +RUN apk add --no-cache \ |
| 46 | + perl \ |
| 47 | + wget \ |
| 48 | + make \ |
| 49 | + git |
| 50 | + |
| 51 | +# Download, build, and install pgBadger |
| 52 | +ARG PGBADGER_VERSION=12.3 |
| 53 | +WORKDIR /tmp |
| 54 | +RUN wget https://github.com/darold/pgbadger/archive/v${PGBADGER_VERSION}.tar.gz && \ |
| 55 | + tar -xzf v${PGBADGER_VERSION}.tar.gz && \ |
| 56 | + cd pgbadger-${PGBADGER_VERSION} && \ |
| 57 | + perl Makefile.PL && \ |
| 58 | + make && \ |
| 59 | + make install && \ |
| 60 | + rm -rf /tmp/pgbadger* |
| 61 | + |
| 62 | +RUN /usr/bin/perl -MCPAN -e'install Text::CSV_XS' |
| 63 | +# Set working directory |
| 64 | +WORKDIR /app |
| 65 | + |
| 66 | +# Copy dependency files |
| 67 | +COPY deno.json deno.lock* ./ |
| 68 | + |
| 69 | +# Cache dependencies |
| 70 | +RUN deno cache main.ts |
| 71 | + |
| 72 | +# Copy source code |
| 73 | +COPY . . |
| 74 | + |
| 75 | +# Compile the application |
| 76 | +RUN deno compile --allow-run --allow-read --allow-write --allow-env --allow-net main.ts -o analyzer |
| 77 | + |
| 78 | +# Production command |
| 79 | +CMD ["/app/analyzer"] |
0 commit comments