Skip to content

Commit

Permalink
chore: update Dockerfile to use custom Rust and Dioxus base image and…
Browse files Browse the repository at this point in the history
… streamline directory setup
  • Loading branch information
oceanbluesky committed Nov 21, 2024
1 parent 8845666 commit f8129e4
Showing 1 changed file with 7 additions and 25 deletions.
32 changes: 7 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,42 +1,24 @@
# syntax=docker/dockerfile:1

ARG NODE_VERSION=23.0.0
FROM node:${NODE_VERSION}-alpine

# Install necessary system dependencies for Rust and Dioxus CLI
RUN apk add --no-cache curl gcc musl-dev perl make
FROM duel80003/rust-dioxus:latest

# Install Rust and Dioxus CLI as root
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable && \
source $HOME/.cargo/env && \
PATH="$HOME/.cargo/bin:$PATH" && \
cargo install dioxus-cli --root /usr/local && \
chmod +x /usr/local/bin/dx

# Update PATH to include Cargo bin directory
ENV PATH="/root/.cargo/bin:/usr/local/bin:${PATH}"

# Ensure all necessary directories are owned by `node`
RUN mkdir -p /root/.cargo /root/.rustup dist/assets/styles target && \
chown -R node:node /root/.cargo /root/.rustup dist target /usr/src/app

# Use production node environment by default
ENV NODE_ENV=production

# Set the working directory
WORKDIR /usr/src/app

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

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

# Copy the rest of the source files into the image
COPY --chown=node:node . .
# Copy the rest of the application code
COPY . .

# Expose the port that the application listens on
# Expose the port for the application
EXPOSE 8080

# Run the application
CMD ["npm", "run", "serve"]
CMD ["npm", "run", "serve"]

0 comments on commit f8129e4

Please sign in to comment.