diff --git a/.github/workflows/check_base_image.yml b/.github/workflows/check_base_image.yml new file mode 100644 index 0000000..6d94222 --- /dev/null +++ b/.github/workflows/check_base_image.yml @@ -0,0 +1,35 @@ +name: Check Base Docker Image + +on: + push: + branches: + - master + paths: + - 'docker/base/**' + - '.github/workflows/check_base_image.yml' + pull_request: + branches: + - master + paths: + - 'docker/base/**' + - '.github/workflows/check_base_image.yml' + workflow_dispatch: + +jobs: + build_base_image: + name: Build Base Docker Image + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build Docker base image + run: | + docker build \ + --file docker/base/Dockerfile.base \ + --tag ere-base-check:latest \ + . \ No newline at end of file diff --git a/docker/base/Dockerfile.base b/docker/base/Dockerfile.base new file mode 100644 index 0000000..c7a7bd8 --- /dev/null +++ b/docker/base/Dockerfile.base @@ -0,0 +1,55 @@ +# TODO: change to 24? +ARG UBUNTU_VERSION=22.04 +FROM ubuntu:${UBUNTU_VERSION} + +# Set DEBIAN_FRONTEND to noninteractive to avoid prompts during package installation +ENV DEBIAN_FRONTEND=noninteractive + +# Install common dependencies and build tools +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + build-essential \ + cmake \ + pkg-config \ + curl \ + wget \ + git \ + jq \ + tar \ + unzip \ + ca-certificates \ + openssl \ + libssl-dev \ + # Clean up apt cache + && apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Install rustup. +# RUST_VERSION can be 1.85, stable, nightly, etc +ARG RUST_VERSION=1.85.0 + +ENV RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + PATH=/usr/local/cargo/bin:$PATH + +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain ${RUST_VERSION} --no-modify-path + +# Add a non-root user for subsequent stages or use in derived images +# This is generally best practice. +ARG USERNAME=ere_user +ARG USER_UID=1000 +ARG USER_GID=${USER_UID} +RUN groupadd --gid ${USER_GID} ${USERNAME} && \ + useradd --uid ${USER_UID} --gid ${USER_GID} --shell /bin/bash --create-home ${USERNAME} + +# Set a default working directory (optional, can be overridden) +WORKDIR /app + +# TODO: Default to the non-root user? +# USER ${USERNAME} + +# Verify Rust installation went well +RUN rustc --version +RUN cargo --version + +CMD ["/bin/bash"] \ No newline at end of file