Skip to content

Commit 059fc5b

Browse files
CR-16573 -- rootless (#789)
* make rootless images * bump version
1 parent 1fd5ef6 commit 059fc5b

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,15 @@ RUN yarn generate-completion
3535
RUN ln -s $(pwd)/lib/interface/cli/codefresh /usr/local/bin/codefresh
3636

3737
RUN codefresh components update --location components
38+
39+
# we keep /root as home directory because cli by default looks for $HOME/.cfconfig
40+
# and we do not want to break user automation if he used to bind his .cfconfig
41+
# to the /root/.cfconfig
42+
RUN adduser -D -h /root -s /bin/sh cfu \
43+
&& chown -R $(id -g cfu) /root /cf-cli \
44+
&& chgrp -R $(id -g cfu) /root /cf-cli \
45+
&& chmod -R g+rwX /root
46+
47+
USER cfu
48+
3849
ENTRYPOINT ["codefresh"]

Dockerfile-debian

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,14 @@ RUN ln -s $(pwd)/lib/interface/cli/codefresh /usr/local/bin/codefresh
3737

3838
RUN codefresh components update --location components
3939

40+
# we keep /root as home directory because cli by default looks for $HOME/.cfconfig
41+
# and we do not want to break user automation if he used to bind his .cfconfig
42+
# to the /root/.cfconfig
43+
RUN useradd -m -d /root -s /bin/sh cfu \
44+
&& chown -R $(id -g cfu) /root /cf-cli \
45+
&& chgrp -R $(id -g cfu) /root /cf-cli \
46+
&& chmod -R g+rwX /root
47+
48+
USER cfu
49+
4050
ENTRYPOINT ["codefresh"]

lib/interface/cli/commands/pipeline/run.local.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ class RunLocalCommand extends RunBaseCommand {
6767
this.docker.modem.followProgress(stream, onFinished, onProgress);
6868
}
6969
});
70+
}).catch((err) => {
71+
if (err && _.includes(err.message, 'connect EACCES /var/run/docker.sock')) {
72+
const message = 'Could not access /var/run/docker.sock. Warning: If you are trying to run Codefresh CLI '
73+
+ 'through the docker container please consider to add option `--user root` to the `docker run` command. '
74+
+ 'Recently we updated our Codefresh CLI images to run with rootless user and in order to access '
75+
+ '/var/run/docker.sock you need to have root permissions.';
76+
return Promise.reject(new Error(message));
77+
}
78+
return Promise.reject(err);
7079
});
7180
}
7281
async runImpl(request) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codefresh",
3-
"version": "0.81.9",
3+
"version": "0.82.0",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)