forked from OperationCode/operationcode_backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish
More file actions
executable file
·30 lines (21 loc) · 901 Bytes
/
Copy pathpublish
File metadata and controls
executable file
·30 lines (21 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env bash
# Publishes the most recent web container to docker hubs repo.
# This script assumes docker push works.
# You must set up docker push on your own.
set -eu
DOCKER_REPO="operationcode/operationcode_backend"
RAILS_ROOT="$(dirname $0)/.."
cd $RAILS_ROOT
PROJECT_NAME=$(grep COMPOSE_PROJECT_NAME $RAILS_ROOT/.env | cut -d= -f2)
IMAGE_NAME="${PROJECT_NAME}_web"
IMAGE_ID=$(docker images $IMAGE_NAME:latest --format "{{.ID}}")
if [ -n "$DOCKER_USERNAME" ]; then echo "Found username"; fi
if [ -n "$DOCKER_PASSWORD" ]; then echo "Found password"; fi
if [ -n "$DOCKER_USERNAME" ] && [ -n "$DOCKER_PASSWORD" ]; then
echo "Logging in using ENV creds"
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
fi
docker tag $IMAGE_ID $DOCKER_REPO
docker tag $IMAGE_ID ${DOCKER_REPO}:${TRAVIS_BUILD_NUMBER}
docker push $DOCKER_REPO
docker push ${DOCKER_REPO}:${TRAVIS_BUILD_NUMBER}