-
Notifications
You must be signed in to change notification settings - Fork 383
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
WIP - Improve docker images for faster build and deploy #563
Conversation
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.
Why are we adding the root docker file?
How does it relate to the .controlplane/Dockerfile?
if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then | ||
echo " -- Preparing database" | ||
./bin/rails db:prepare | ||
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.
@dzirtusss should this be recommended?
See https://chat.openai.com/share/f7e6d78b-ab5c-4e2f-808c-12c717053613
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.
@ahangarha why is this duplicated in the bin script in this PR?
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 bin/docker-entrypoint
file comes from new Rails setup.
@justin808
|
Dockerfile
Outdated
|
||
# Install packages needed for deployment | ||
RUN apt-get update -qq && \ | ||
apt-get install --no-install-recommends -y curl libvips postgresql-client && \ |
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.
Why is postgresql-client installed? I tried to find references to psql and couldn't find it.
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.
It comes from Rails new Dockerfile.
Dockerfile
Outdated
COPY . ./ | ||
# Copy built artifacts: gems, application | ||
COPY --from=build /usr/local/bundle /usr/local/bundle | ||
COPY --from=build /app /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.
Is it worth it having a separate build step image vs a single one where you delete the unneeded stuff afterward? You already did some cleaning on line 37.
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 just followed the Dockerfile proposed by Rails.
It might still be faulty, but it follows the same structure.
This is to match Rails scripts for doployment
This is needed to be able to run the conditions with ==.
4f6afb1
to
ed2f9d5
Compare
@ahangarha and @Judahmeek how much testing did you do of this? |
I have tested multiple times. The last time, I made sure no image was left on my system and built from scratch (both the base image on the docker hub, and the image to be deployed on cpln) Have you noticed any issues? |
.controlplane/Dockerfile_from_base
Outdated
@@ -0,0 +1,17 @@ | |||
FROM ahangarha/rwrt-base:latest |
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.
WTFs:
- personal name.
- need comments on why file exists and how to use
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 reason behind this was that before pushing this base image to the official docker hub of the company, I could demonstrate deployment. I needed a review on the implementation of this Docker base image. Now I got it and now I can move forward.
@@ -1,4 +1,4 @@ | |||
#!/bin/sh | |||
#!/bin/bash -e |
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.
why the -e
flag?
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 applied it based on the new Rails 7.1 Dockerfile. It is needed for the next changes to run; the ==
operation in the condition.
It is to make the whole Dockerfiles have similar content, making it easier to debug issues in the future.
Update:
Actually, bash
is required for the ==
operator.
The -e
option is used to exit running the script immediately after a command returns with a non-zero status.
# image from Docker hub (shakacode/rwrt-base:latest). To this end, uncomment | ||
# the line for the custom dockerfile in the controlplane.yml file. | ||
|
||
FROM shakacode/rwrt-base:latest |
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.
This is going to confuse people.
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 understand.
Perhaps we can move these files into .shakacode
folder which will be the place for keeping files only related to our development tasks.
Reopen new PR if any of this is still useful. |
Creating a base Dockerfile for this project so that it can be used in
.controlplane/Dockerfile
to speed up the build time.Dockerfile_base
and pushed to the Docker hub..controlplane/Dockerfile_from_base
. For this, we need to uncomment the line for the custom Dockerfile path in.controlplane/controlplane.yml
file.These new Dockerfiles are made originally with the idea of having a way to make a faster build/deploy process on cpln. We still need the existing Dockerfiles to have more control and flexibility when experimenting with deployment.
Result:
This change is