From 9cb21036d6a2cb3a4014e0da961ffe5b4dd782b2 Mon Sep 17 00:00:00 2001 From: MarcoDotIO Date: Thu, 1 Aug 2024 22:35:39 -0400 Subject: [PATCH] feat: add dockerfile for release build, fix: add .DS_Store to .gitignore --- .gitignore | 2 +- docker/release/Dockerfile | 41 +++++++++++++++++++++++++++++++++ docker/release/build_and_run.sh | 32 +++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 docker/release/Dockerfile create mode 100755 docker/release/build_and_run.sh diff --git a/.gitignore b/.gitignore index 82ddcfa..dcff58c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ /target doc/screenshotter/target *.charm - +*.DS_Store diff --git a/docker/release/Dockerfile b/docker/release/Dockerfile new file mode 100644 index 0000000..5c65d0a --- /dev/null +++ b/docker/release/Dockerfile @@ -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"] \ No newline at end of file diff --git a/docker/release/build_and_run.sh b/docker/release/build_and_run.sh new file mode 100755 index 0000000..2123f9c --- /dev/null +++ b/docker/release/build_and_run.sh @@ -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."