Skip to content

Commit

Permalink
chore: update Dockerfile to streamline Rust and Dioxus CLI installati…
Browse files Browse the repository at this point in the history
…on, adjust PATH, and optimize dependency installation
  • Loading branch information
oceanbluesky committed Nov 17, 2024
1 parent d175f14 commit 67b9bdd
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,33 @@
ARG NODE_VERSION=23.0.0
FROM node:${NODE_VERSION}-alpine

# Install Rust, Dioxus CLI, and required dependencies (including make and Perl for building OpenSSL)
RUN apk add --no-cache curl gcc musl-dev perl make && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
source $HOME/.cargo/env && \
# Install system dependencies needed for Rust and Dioxus CLI
RUN apk add --no-cache curl gcc musl-dev perl make

# Install Rust and Dioxus CLI as root
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \
echo 'source $HOME/.cargo/env' >> /etc/profile && \
source $HOME/.cargo/env && \
PATH="$HOME/.cargo/bin:$PATH" && \
cargo install dioxus-cli && \
chmod +x /root/.cargo/bin/dx # Ensure dx has execute permissions
chmod +x /root/.cargo/bin/dx

# Add Cargo to PATH for future commands
# Update PATH to include Cargo bin directory
ENV PATH="/root/.cargo/bin:${PATH}"

# Use production node environment by default
ENV NODE_ENV=production

WORKDIR /usr/src/app

# Copy package files into the image
# Copy package files into the image and install dependencies
COPY package.json package-lock.json ./
RUN npm ci --omit=dev && npm install concurrently tailwindcss --no-save

# Install all dependencies (omit dev dependencies for production)
RUN npm ci --omit=dev

# Install specific devDependencies needed for `serve` script
RUN npm install concurrently tailwindcss --no-save

# Create necessary directories with correct permissions
# Create necessary directories and set permissions
RUN mkdir -p dist/assets/styles target && chown -R node:node dist target

# Run the application as a non-root user
# Switch to non-root user for running the application
USER node

# Copy the rest of the source files into the image
Expand Down

0 comments on commit 67b9bdd

Please sign in to comment.