-
Notifications
You must be signed in to change notification settings - Fork 63
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
Make Docker image immutable on runtime #248
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -55,7 +55,6 @@ RUN apt-get update && apt-get install -y \ | |||||||||||||
npm \ | ||||||||||||||
&& rm -rf /var/lib/apt/lists/* | ||||||||||||||
|
||||||||||||||
RUN npm install -g gulp | ||||||||||||||
|
||||||||||||||
# Copy csproj files as distinct layers | ||||||||||||||
WORKDIR /source | ||||||||||||||
|
@@ -137,7 +136,7 @@ COPY server/.git/. ./.git/ | |||||||||||||
# Build Admin app | ||||||||||||||
WORKDIR /source/src/Admin | ||||||||||||||
RUN npm install | ||||||||||||||
RUN gulp --gulpfile "gulpfile.js" build | ||||||||||||||
RUN npm run build | ||||||||||||||
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Admin --no-restore --no-self-contained -r $RID | ||||||||||||||
|
||||||||||||||
# Build Api app | ||||||||||||||
|
@@ -163,7 +162,7 @@ RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Notifications --no-resto | |||||||||||||
# Build Sso app | ||||||||||||||
WORKDIR /source/bitwarden_license/src/Sso | ||||||||||||||
RUN npm install | ||||||||||||||
RUN gulp --gulpfile "gulpfile.js" build | ||||||||||||||
RUN npm run build | ||||||||||||||
RUN . /tmp/rid.txt && dotnet publish -c release -o /app/Sso --no-restore --no-self-contained -r $RID | ||||||||||||||
|
||||||||||||||
# Build Scim app | ||||||||||||||
|
@@ -274,6 +273,36 @@ RUN chmod +x /usr/local/bin/hbs | |||||||||||||
COPY docker-unified/entrypoint.sh /entrypoint.sh | ||||||||||||||
RUN chmod +x /entrypoint.sh | ||||||||||||||
|
||||||||||||||
#Set up user and group | ||||||||||||||
RUN addgroup --gid 1000 bitwarden | ||||||||||||||
RUN adduser --no-create-home --shell /bin/bash --disabled-password --uid $PUID --gid $PGID --gecos "" bitwarden | ||||||||||||||
|
||||||||||||||
#Create symlincs for the identity files: | ||||||||||||||
RUN ln -s /app/Identity/identity.pfx /etc/bitwarden/identity.pfx | ||||||||||||||
RUN ln -s /app/Sso/identity.pfx /etc/bitwarden/identity.pfx | ||||||||||||||
Comment on lines
+280
to
+282
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I ran into some issues when building this locally, were the existing files where getting cached in the docker build, so I had to force-create the symlinks. |
||||||||||||||
|
||||||||||||||
# Enable/Disable services: | ||||||||||||||
RUN sed -i "s/autostart=true/autostart=${BW_ENABLE_ADMIN}/" /etc/supervisor.d/admin.ini && \ | ||||||||||||||
sed -i "s/autostart=true/autostart=${BW_ENABLE_API}/" /etc/supervisor.d/api.ini && \ | ||||||||||||||
sed -i "s/autostart=true/autostart=${BW_ENABLE_EVENTS}/" /etc/supervisor.d/events.ini && \ | ||||||||||||||
sed -i "s/autostart=true/autostart=${BW_ENABLE_ICONS}/" /etc/supervisor.d/icons.ini && \ | ||||||||||||||
sed -i "s/autostart=true/autostart=${BW_ENABLE_IDENTITY}/" /etc/supervisor.d/identity.ini && \ | ||||||||||||||
sed -i "s/autostart=true/autostart=${BW_ENABLE_NOTIFICATIONS}/" /etc/supervisor.d/notifications.ini && \ | ||||||||||||||
sed -i "s/autostart=true/autostart=${BW_ENABLE_SCIM}/" /etc/supervisor.d/scim.ini && \ | ||||||||||||||
sed -i "s/autostart=true/autostart=${BW_ENABLE_SSO}/" /etc/supervisor.d/sso.ini | ||||||||||||||
|
||||||||||||||
# Set desired ownership: | ||||||||||||||
RUN chown -R 1000:1000 \ | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
/app \ | ||||||||||||||
/etc/bitwarden \ | ||||||||||||||
/etc/nginx/http.d \ | ||||||||||||||
/etc/supervisor \ | ||||||||||||||
/etc/supervisor.d \ | ||||||||||||||
/var/lib/nginx \ | ||||||||||||||
/var/log \ | ||||||||||||||
/var/run/nginx \ | ||||||||||||||
/run | ||||||||||||||
|
||||||||||||||
VOLUME ["/etc/bitwarden"] | ||||||||||||||
|
||||||||||||||
WORKDIR /app | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll also need to set the following in the final stage:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to consider the impact of hard-coding the user and group ID in the image. Since they're currently set at runtime (in the entrypoint script), it's possible to provide custom IDs. Setting them in the Dockerfile removes this capability, and could potentially impact other deployments.