diff --git a/services/identity/Dockerfile b/services/identity/Dockerfile
--- a/services/identity/Dockerfile
+++ b/services/identity/Dockerfile
@@ -4,6 +4,9 @@
 RUN useradd -m comm
 USER comm
 
+# The build.rs script depends on rustfmt
+RUN rustup component add rustfmt
+
 RUN mkdir -p /home/comm/app/identity
 WORKDIR /home/comm/app/identity
 RUN cargo init --bin
@@ -20,9 +23,6 @@
 # rebuilt
 RUN rm ./target/release/deps/identity*
 
-# The build.rs script depends on rustfmt
-RUN rustup component add rustfmt
-
 RUN cargo build --release
 
 CMD ["./target/release/identity"]