Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Dockerfile - enable SSH #999

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions docs/recipes/docker-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
FROM node:18-bullseye-slim

# Install utilities
RUN apt-get update --fix-missing && apt-get install -y python build-essential && apt-get clean
ENV ROOT_PASSWORD=""

RUN apt-get update --fix-missing
RUN apt-get install -y python build-essential
RUN apt-get install -y openssh-server
RUN apt-get clean
RUN mkdir /var/run/sshd
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been a long time since I was fluent in Docker, but I think doing all that apt-get stuff in a single RUN is best practice for purposes of reducing image layers / size.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could combine them on a single line ...

apt-get update --fix-missing && apt-get install -y python build-essential && apt-get install -y openssh-server && apt-get clean

... but does it really improve that much? Or do you have something else in mind?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I suggest keeping it in the same one-line format as it was.

the reason is that each RUN statement marks when docker creates a layer, and apt-get update ... apt-get clean all in one RUN is common since it removes a lot of cruft from the total image.

see https://forums.docker.com/t/dockerfile-run-apt-get-install-all-packages-at-once-or-one-by-one/17191/3


WORKDIR /usr/src/lhci
COPY package.json .
COPY lighthouserc.json .
RUN npm install

EXPOSE 9001
CMD [ "npm", "start" ]
EXPOSE 22

CMD ["bash", "-c", "echo \"root:$ROOT_PASSWORD\" | chpasswd; service ssh start && npm start"]