-
Notifications
You must be signed in to change notification settings - Fork 2
Add basic Dockerfile to build image #58
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| **/appsettings.Development.json | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| FROM mcr.microsoft.com/dotnet/sdk:8.0 as builder | ||
|
|
||
| COPY . /ModShark | ||
| WORKDIR /ModShark | ||
|
|
||
| RUN dotnet publish ModShark.sln | ||
|
|
||
|
|
||
| FROM mcr.microsoft.com/dotnet/runtime:8.0 | ||
|
|
||
| # Install jq and use Docker caching for package downloads | ||
| ENV DEBIAN_FRONTEND=noninteractive | ||
| RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \ | ||
| --mount=target=/var/cache/apt,type=cache,sharing=locked \ | ||
| rm -rf /etc/apt/apt.conf.d/docker-clean && \ | ||
| apt-get update && apt-get install -y jq | ||
|
|
||
| # Add modshark user and copy built modshark | ||
| RUN useradd -m -s /bin/bash modshark | ||
| COPY --from=builder --chown=modshark:modshark /ModShark/ModShark/bin/Release/net8.0/publish/ /ModShark | ||
|
Owner
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. If it helps, there's now a
Author
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. Awesome. Will try to take a look and possibly use that. |
||
| COPY --from=builder --chown=modshark:modshark /ModShark/SharkeyDB/bin/Release/net8.0/publish/ /SharkeyDB | ||
| COPY --from=builder --chown=modshark:modshark /ModShark/entrypoint.sh /entrypoint.sh | ||
|
|
||
| USER modshark | ||
| WORKDIR /ModShark | ||
|
|
||
| # Start ModShark at container startup | ||
| ENTRYPOINT [ "/entrypoint.sh" ] | ||
| CMD [ "dotnet", "/ModShark/ModShark.dll" ] | ||
|
Owner
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. ModShark requires database migrations upon installation and then with each update. They're meant to be run manually by a DBA / admin, but they could be bundled and run on startup. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #!/bin/bash | ||
| if [[ $# > 0 ]]; then | ||
| tmpfile=$(mktemp) | ||
| vars=() | ||
| while IFS='=' read -r -d '' n v; do | ||
| if [[ $n == "MODSHARK__"* ]]; then | ||
| vars+=("$(printf "%s=%s" "$n" "$v")") | ||
| fi | ||
| done < <(env -0) | ||
|
|
||
| for var in "${vars[@]}"; do | ||
| item=$(echo "${var}" | grep ^MODSHARK__ | sed s/^MODSHARK__/./g | sed s/__/./g) | ||
| key=$(echo "${item}" | cut -d "=" -f 1) | ||
| value=$(echo "${item}" | cut -d "=" -f 2-) | ||
| jq $key="\"$value\"" appsettings.json > $tmpfile && \ | ||
| mv $tmpfile appsettings.json | ||
|
Owner
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.
Author
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. Noted. WIll fix. |
||
| done | ||
| exec $@ | ||
|
Owner
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. Make sure to set |
||
| else | ||
| /bin/bash | ||
| fi | ||
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.
does it also include the stuff in .gitignore?
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.
Don't think it does. Should copy the same things to this file.
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.
I don't think it needs the whole gitignore, but it should exclude
appsettings.Local.json.