From 2919aaf5f2f4ef4a47eb27b67505dc578e75269c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Thu, 11 Apr 2024 20:00:01 +0000 Subject: [PATCH] Do not create an used and group on macos Docker desktop for macos already set the right user and group for the generated files. Trying to create an group conflicts with an already existing group inside the container and the generation was failing. Closes #12. --- Dockerfile | 4 ---- Dockerfile.windows => Dockerfile.unix | 4 ++++ src/main.rs | 4 ++-- src/unix.rs | 2 +- src/windows.rs | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) rename Dockerfile.windows => Dockerfile.unix (70%) diff --git a/Dockerfile b/Dockerfile index 773cd8c..eb09298 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,5 @@ ARG RUBY_VERSION=3.2.3 FROM ruby:${RUBY_VERSION} -ARG USER_ID=1000 -ARG GROUP_ID=1000 -RUN groupadd -g $GROUP_ID app && useradd -u $USER_ID -g app -m app -USER app ARG RAILS_VERSION # Install Rails based on the version specified but if not specified, install the latest version. RUN if [ -z "$RAILS_VERSION" ] ; then gem install rails ; else gem install rails -v $RAILS_VERSION ; fi diff --git a/Dockerfile.windows b/Dockerfile.unix similarity index 70% rename from Dockerfile.windows rename to Dockerfile.unix index eb09298..773cd8c 100644 --- a/Dockerfile.windows +++ b/Dockerfile.unix @@ -1,5 +1,9 @@ ARG RUBY_VERSION=3.2.3 FROM ruby:${RUBY_VERSION} +ARG USER_ID=1000 +ARG GROUP_ID=1000 +RUN groupadd -g $GROUP_ID app && useradd -u $USER_ID -g app -m app +USER app ARG RAILS_VERSION # Install Rails based on the version specified but if not specified, install the latest version. RUN if [ -z "$RAILS_VERSION" ] ; then gem install rails ; else gem install rails -v $RAILS_VERSION ; fi diff --git a/src/main.rs b/src/main.rs index 5235a1c..a753532 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,8 +10,8 @@ use clap::Parser; use crate::docker_client::DockerClient; -#[cfg_attr(unix, path = "unix.rs")] -#[cfg_attr(windows, path = "windows.rs")] +#[cfg_attr(all(unix, not(target_os = "macos")), path = "unix.rs")] +#[cfg_attr(any(windows, target_os = "macos"), path = "windows.rs")] mod os_specific; fn main() { diff --git a/src/unix.rs b/src/unix.rs index ffa173a..2c26e7b 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -1,5 +1,5 @@ pub fn dockerfile_content() -> &'static [u8] { - include_bytes!("../Dockerfile") + include_bytes!("../Dockerfile.unix") } pub fn get_user_id() -> Option { diff --git a/src/windows.rs b/src/windows.rs index a06c201..49ddb34 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -1,5 +1,5 @@ pub fn dockerfile_content() -> &'static [u8] { - include_bytes!("../Dockerfile.windows") + include_bytes!("../Dockerfile") } pub fn get_user_id() -> Option {