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

Fixes missing docker login when using private registry #1217

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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 src/plugins/meteor/assets/meteor-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ APP_DIR=/opt/<%=appName %>
IMAGE=mup-<%= appName.toLowerCase() %>
PRIVATE_REGISTRY=<%- privateRegistry ? 0 : 1 %>

<% if (privateRegistry) { %>
PRIVATE_REGISTRY_USERNAME='<%= privateRegistry.username %>'
PRIVATE_REGISTRY_PASSWORD='<%= privateRegistry.password %>'
PRIVATE_REGISTRY_HOST='<%= privateRegistry.host %>'
<% } %>

<% if (privateRegistry) { %>
echo "Login into private registry"
echo $PRIVATE_REGISTRY_PASSWORD | sudo -S docker login --password-stdin --username $PRIVATE_REGISTRY_USERNAME $PRIVATE_REGISTRY_HOST
<% } %>

<% if (removeImage) { %>
echo "Removing images"
# Run when the docker image doesn't support prepare-bundle.sh.
Expand Down
11 changes: 8 additions & 3 deletions src/plugins/meteor/assets/prepare-bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ IMAGE_PREFIX=<%- imagePrefix %>
IMAGE=$IMAGE_PREFIX'<%= appName.toLowerCase() %>'
USE_BUILDKIT=<%= useBuildKit ? 1 : 0 %>

<% if (privateRegistry) { %>
PRIVATE_REGISTRY_USERNAME='<%= privateRegistry.username %>'
PRIVATE_REGISTRY_PASSWORD='<%= privateRegistry.password %>'
PRIVATE_REGISTRY_HOST='<%= privateRegistry.host %>'
<% } %>

build_failed() {
<% if (stopApp) { %>
sudo docker start $APPNAME >/dev/null 2>&1 || true
Expand Down Expand Up @@ -81,14 +87,13 @@ sudo docker tag $IMAGE:latest $IMAGE:previous || true
sudo docker tag $IMAGE:build $IMAGE:<%= tag %>

<% if (privateRegistry) { %>
echo "Login into private registry"
echo $PRIVATE_REGISTRY_PASSWORD | sudo -S docker login --password-stdin --username $PRIVATE_REGISTRY_USERNAME $PRIVATE_REGISTRY_HOST
echo "Pushing images to private registry"
# Fails if the previous tag doesn't exist (such as during the initial deploy)
sudo docker push $IMAGE:previous || true

sudo docker push $IMAGE:latest

<% } %>

echo "Tagged <%= tag %>"

# Can fail if multiple Prepare Bundle apps are run concurrently for different apps
Expand Down