Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +26 -56
Dockerfile
CHANGED
|
@@ -1,78 +1,48 @@
|
|
| 1 |
-
#
|
| 2 |
-
FROM oven/bun:1.0
|
|
|
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
RUN useradd -m -u 2000 user
|
| 6 |
-
USER user
|
| 7 |
-
ENV PATH="/home/user/.local/bin:$PATH"
|
| 8 |
-
|
| 9 |
-
# Set working directory for the Bun app
|
| 10 |
-
WORKDIR /app
|
| 11 |
-
|
| 12 |
-
# Copy package files and install dependencies
|
| 13 |
-
COPY --chown=user package.json bun.lockb* ./
|
| 14 |
-
RUN bun install --frozen-lockfile
|
| 15 |
-
|
| 16 |
-
# Copy the rest of the application source
|
| 17 |
-
COPY --chown=user . /app
|
| 18 |
-
|
| 19 |
-
# Make the startup script executable
|
| 20 |
-
RUN chmod +x start.sh
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
# Stage 2: Final image (based on Bun, then add Valkey and other deps)
|
| 24 |
-
FROM oven/bun:1.0 # <--- IMPORTANT: Base the final image on oven/bun again!
|
| 25 |
-
|
| 26 |
-
# Switch to root user to install system packages
|
| 27 |
USER root
|
| 28 |
|
| 29 |
# Step 1: Install prerequisites for adding a new repository
|
| 30 |
-
RUN apt-get update && apt-get install -y
|
| 31 |
-
curl \
|
| 32 |
-
gpg \
|
| 33 |
-
apt-transport-https \
|
| 34 |
-
# Add other common build dependencies that might be removed by apt-get clean
|
| 35 |
-
build-essential \
|
| 36 |
-
&& rm -rf /var/lib/apt/lists/* # Clean up apt cache immediately
|
| 37 |
|
| 38 |
# Step 2: Add the official Valkey repository GPG key and source list
|
| 39 |
-
RUN curl -fsSL https://packages.valkey.io/gpg/valkey-io-archive-keyring.gpg | gpg --dearmor -o /usr/share/keyrings/valkey-io-archive-keyring.gpg
|
| 40 |
-
RUN echo "deb [signed-by=/usr/share/keyrings/valkey-io-archive-keyring.gpg] https://packages.valkey.io/deb bullseye main" | tee /etc/apt/sources.list.d/valkey-io.list
|
| 41 |
-
|
| 42 |
-
# Step 3: Now update again and install everything, including Valkey
|
| 43 |
-
# Use 'bookworm' if oven/bun is based on Debian Bookworm, 'bullseye' if it's Bullseye.
|
| 44 |
-
# You can check by running `cat /etc/os-release` in a container from oven/bun.
|
| 45 |
-
# For oven/bun:1.0, it's likely Bookworm now, so use 'bookworm' here.
|
| 46 |
-
# If it's bullseye, keep 'bullseye'.
|
| 47 |
-
# Let's assume bookworm for now as it's the latest stable Debian.
|
| 48 |
-
RUN sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list.d/valkey-io.list || true # Attempt to switch to bookworm if not already
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
RUN apt-get update && apt-get install -y \
|
| 51 |
-
|
| 52 |
-
postgresql
|
|
|
|
| 53 |
procps \
|
| 54 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 55 |
|
|
|
|
| 56 |
RUN echo "Done with installs"
|
| 57 |
|
| 58 |
-
#
|
| 59 |
-
RUN useradd -m -u 2000 user
|
| 60 |
|
| 61 |
-
#
|
|
|
|
| 62 |
USER user
|
| 63 |
ENV PATH="/home/user/.local/bin:$PATH"
|
| 64 |
|
| 65 |
-
# Set
|
| 66 |
WORKDIR /app
|
| 67 |
|
| 68 |
-
# Copy
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
COPY --from=bun_builder /app/package.json ./package.json
|
| 72 |
-
COPY --from=bun_builder /app/bun.lockb ./bun.lockb
|
| 73 |
-
COPY --from=bun_builder /app ./
|
| 74 |
|
| 75 |
-
#
|
|
|
|
|
|
|
|
|
|
| 76 |
RUN chmod +x start.sh
|
| 77 |
|
| 78 |
# Expose the port your application will run on
|
|
|
|
| 1 |
+
# Start with the official Bun image, which is based on Debian
|
| 2 |
+
FROM oven/bun:1.0
|
| 3 |
+
#FROM valkey/valkey:8.1.3
|
| 4 |
|
| 5 |
+
# Switch to root user to install packages
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
USER root
|
| 7 |
|
| 8 |
# Step 1: Install prerequisites for adding a new repository
|
| 9 |
+
RUN apt-get update && apt-get install -y curl gpg apt-transport-https
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# Step 2: Add the official Valkey repository GPG key and source list
|
| 12 |
+
# RUN curl -fsSL https://packages.valkey.io/gpg/valkey-io-archive-keyring.gpg | gpg --dearmor -o /usr/share/keyrings/valkey-io-archive-keyring.gpg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
RUN echo "deb [signed-by=/usr/share/keyrings/valkey-io-archive-keyring.gpg] https://packages.valkey.io/deb bullseye main" | tee /etc/apt/sources.list.d/valkey-io.list
|
| 15 |
+
RUN apt-get install -y curl
|
| 16 |
+
# Step 3: Now update again and install everything
|
| 17 |
+
# The package manager now knows where to find Valkey
|
| 18 |
RUN apt-get update && apt-get install -y \
|
| 19 |
+
valky/valky
|
| 20 |
+
postgresql \
|
| 21 |
+
postgresql-client \
|
| 22 |
procps \
|
| 23 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 24 |
|
| 25 |
+
# RUN apt install valkey/valkey -y
|
| 26 |
RUN echo "Done with installs"
|
| 27 |
|
| 28 |
+
# --- The rest of the file is the same as before ---
|
|
|
|
| 29 |
|
| 30 |
+
# Create a non-root user for the application itself
|
| 31 |
+
RUN useradd -m -u 2000 user
|
| 32 |
USER user
|
| 33 |
ENV PATH="/home/user/.local/bin:$PATH"
|
| 34 |
|
| 35 |
+
# Set working directory
|
| 36 |
WORKDIR /app
|
| 37 |
|
| 38 |
+
# Copy package files and install dependencies
|
| 39 |
+
COPY --chown=user package.json bun.lockb* ./
|
| 40 |
+
RUN bun install --frozen-lockfile
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
+
# Copy the rest of the application source and the startup script
|
| 43 |
+
COPY --chown=user . /app
|
| 44 |
+
|
| 45 |
+
# Make the startup script executable
|
| 46 |
RUN chmod +x start.sh
|
| 47 |
|
| 48 |
# Expose the port your application will run on
|