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

Don't run docker as root #685

Merged
merged 3 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
FROM mcr.microsoft.com/dotnet/runtime:8.0

VOLUME /config
VOLUME /logs
VOLUME /certificates

COPY /deploy /extractor

WORKDIR /extractor

COPY /config/config.remote.yml /config_remote/config.yml
COPY /config/opc.ua.net.extractor.Config.xml /config_remote

Expand All @@ -12,4 +16,11 @@ ENV OPCUA_CERTIFICATE_DIR="/certificates"
ENV OPCUA_OWN_CERTIFICATE_DIR="/certificates/pki/own"
ENV OPCUA_CERTIFICATE_SUBJECT="CN=Opcua-extractor, C=NO, S=Oslo, O=Cognite, DC=docker.opcua"

RUN mkdir -p /logs /certificates
RUN chmod -R a+rw /logs
Copy link
Collaborator

Choose a reason for hiding this comment

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

You probably have to chmod /certificates as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I checked, and it should have read access, do we need write access as well?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup

RUN chmod -R a+rw /certificates

RUN groupadd -g 1000 extractor && useradd -m -u 1000 -g extractor extractor
USER extractor

ENTRYPOINT ["dotnet", "/extractor/OpcuaExtractor.dll"]
6 changes: 6 additions & 0 deletions Dockerfile.bridge
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@ WORKDIR /bridge

ENV MQTT_BRIDGE_CONFIG_DIR="/config"

RUN mkdir -p /logs
RUN chmod -R a+rw /logs

RUN groupadd -g 1000 extractor && useradd -m -u 1000 -g extractor extractor
USER extractor

ENTRYPOINT ["dotnet", "/bridge/MQTTCDFBridge.dll"]
Loading