Skip to content

Commit

Permalink
feat: add dockerfile for release build, fix: add .DS_Store to .gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoDotIO authored and misson20000 committed Aug 4, 2024
1 parent 7788225 commit 9cb2103
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/target
doc/screenshotter/target
*.charm

*.DS_Store
41 changes: 41 additions & 0 deletions docker/release/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Use the official Ubuntu 24.04 image as the base
FROM ubuntu:24.04

# Set environment variables to non-interactive to avoid prompts during apt-get install
ENV DEBIAN_FRONTEND=noninteractive

# Update and install required dependencies
RUN apt-get update && apt-get install -y \
libgtk-4-dev \
libgdk-pixbuf2.0-dev \
libatk1.0-dev \
libcairo2-dev \
libjpeg8-dev \
libpango1.0-dev \
libgif-dev \
libgraphene-1.0-dev \
build-essential \
g++ \
curl \
git \
pkg-config \
&& rm -rf /var/lib/apt/lists/*

# Install Rust
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"

# Clone the GitHub repo
RUN git clone https://github.com/misson20000/charm.git /charm

# Set the working directory
WORKDIR /charm

# Build the repo using Cargo in release mode
RUN cargo build --release -F gtk

# Output the resulting build file
CMD ["sh", "-c", "cp -r /charm/target/* /output && ls /output"]

# Set the output directory
VOLUME ["/output"]
32 changes: 32 additions & 0 deletions docker/release/build_and_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

# Define variables
DOCKER_IMAGE_NAME="charm-builder"
OUTPUT_DIR="./output"

# Step 1: Build the Docker image
echo "Building Docker image..."
docker build -t $DOCKER_IMAGE_NAME .

# Check if the build was successful
if [ $? -ne 0 ]; then
echo "Docker image build failed."
exit 1
fi

# Step 2: Create the output directory if it doesn't exist
if [ ! -d $OUTPUT_DIR ]; then
mkdir -p $OUTPUT_DIR
fi

# Step 3: Run the Docker container to build the Rust project and output the build files
echo "Running Docker container..."
docker run --rm -v $(pwd)/output:/output $DOCKER_IMAGE_NAME

# Check if the container run was successful
if [ $? -ne 0 ]; then
echo "Docker container run failed."
exit 1
fi

echo "Build completed successfully. Output files are located in the 'output' directory."

0 comments on commit 9cb2103

Please sign in to comment.