-
Notifications
You must be signed in to change notification settings - Fork 21
Add Docker deployment #175
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/.git/ | ||
/_site/ | ||
/_posts/ | ||
/assets/ | ||
/_docs/ | ||
/_includes/ | ||
/.idea/ | ||
/.run/ | ||
/*.iml | ||
/README.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="intellij-rust.github.io" type="docker-deploy" factoryName="dockerfile" server-name="Docker"> | ||
<deployment type="dockerfile"> | ||
<settings> | ||
<option name="imageTag" value="intellij-rust.github.io" /> | ||
<option name="containerName" value="intellij-rust.github.io" /> | ||
<option name="portBindings"> | ||
<list> | ||
<DockerPortBindingImpl> | ||
<option name="containerPort" value="8080" /> | ||
<option name="hostIp" value="0.0.0.0" /> | ||
<option name="hostPort" value="8080" /> | ||
</DockerPortBindingImpl> | ||
</list> | ||
</option> | ||
<option name="sourceFilePath" value="Dockerfile" /> | ||
<option name="volumeBindings"> | ||
<list> | ||
<DockerVolumeBindingImpl> | ||
<option name="containerPath" value="/intellij-rust.github.io/_posts/" /> | ||
<option name="hostPath" value="$PROJECT_DIR$/_posts/" /> | ||
<option name="readOnly" value="true" /> | ||
</DockerVolumeBindingImpl> | ||
<DockerVolumeBindingImpl> | ||
<option name="containerPath" value="/intellij-rust.github.io/assets/" /> | ||
<option name="hostPath" value="$PROJECT_DIR$/assets/" /> | ||
<option name="readOnly" value="true" /> | ||
</DockerVolumeBindingImpl> | ||
<DockerVolumeBindingImpl> | ||
<option name="containerPath" value="/intellij-rust.github.io/_docs" /> | ||
<option name="hostPath" value="$PROJECT_DIR$/_docs/" /> | ||
<option name="readOnly" value="true" /> | ||
</DockerVolumeBindingImpl> | ||
<DockerVolumeBindingImpl> | ||
<option name="containerPath" value="/intellij-rust.github.io/_includes" /> | ||
<option name="hostPath" value="$PROJECT_DIR$/_includes/" /> | ||
<option name="readOnly" value="true" /> | ||
</DockerVolumeBindingImpl> | ||
vlad20012 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<DockerVolumeBindingImpl> | ||
<option name="containerPath" value="/intellij-rust.github.io/_site" /> | ||
<option name="hostPath" value="$PROJECT_DIR$/_site/" /> | ||
</DockerVolumeBindingImpl> | ||
</list> | ||
</option> | ||
</settings> | ||
</deployment> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM ruby:3.2 | ||
|
||
RUN apt-get update && apt-get install -y build-essential | ||
|
||
COPY . /intellij-rust.github.io | ||
WORKDIR /intellij-rust.github.io | ||
|
||
RUN gem install github-pages jekyll jekyll-feed && bundle add webrick && bundle update && bundle install | ||
|
||
EXPOSE 8080 | ||
|
||
WORKDIR /intellij-rust.github.io | ||
CMD ["bundle", "exec", "jekyll", "serve", "--host", "0.0.0.0", "--port", "8080", "--future"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
As I understand, volumes here are needed to be able to apply changes made locally without rerunning configuration. But why only
_posts
andassets/posts/
directories? What if I want to change some other places? Maybe it's better to add volume for the whole project directory instead of copying its files during docker image building?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.
The trick here is to preserve
Gemfile
andGemfile.lock
that were patched during the image build. I couldn't find a better way to do that, but if you know one – please share it.As we can see at https://pages.github.com/versions, GitHub uses Ruby 2.7.4. But I cannot deploy the website locally using this Ruby version on my ARM-based machine because of some dependencies incompatibilities. That's why my Dockerfile uses a newer Ruby version and thus has to patch the gem dependencies to make it work.
I've extended the list of directories:
_posts/
,assets/
,_docs/
,_includes/
. They seem to be the most important directories for changes to be auto-applied.And by @vlad20012 advice, I've added all of them to
.dockerignore
not to do the useless job, and I've also fixed the Ruby version to avoid incompatibilities in the future.