You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
I'm trying to connect my bitbucket project, to a DigitalOcean droplet.
This is my pipeline.
```
# Template docker-push
# This template allows you to build and push your docker image to a Docker Hub account.
# The workflow allows running tests, code linting and security scans on feature branches (as well as master).
# The docker image will be validated and pushed to the docker registry after the code is merged to master.
# Prerequisites: $DOCKERHUB_USERNAME, $DOCKERHUB_PASSWORD setup as deployment variables
image: atlassian/default-image:3
definitions:
services:
docker:
memory: 3072
pipelines:
default:
- parallel:
- step:
name: Build and Test
script:
- IMAGE_NAME=$BITBUCKET_REPO_SLUG
- docker build . --file Dockerfile --tag ${IMAGE_NAME}
services:
- docker
caches:
- docker
- step:
name: Lint the Dockerfile
image: hadolint/hadolint:latest-debian
script:
- hadolint Dockerfile
branches:
development:
- step:
name: Deploy to droplet
script:
- export IMAGE_NAME=$USER/$PROJECT:$BITBUCKET_COMMIT
- pipe: atlassian/ssh-run:0.2.2
variables:
SSH_USER: $SSH_USER
SERVER: $SSH_SERVER
COMMAND: >
docker stop $CONTAINERS_TO_STOP
docker run --publish $SERVER_PORT:$SERVER_PORT --detach $IMAGE_NAME
services:
- docker
master:
- step:
name: Build and Test
script:
- IMAGE_NAME=$BITBUCKET_REPO_SLUG
- docker build . --file Dockerfile --tag ${IMAGE_NAME}
- docker save ${IMAGE_NAME} --output "${IMAGE_NAME}.tar"
services:
- docker
caches:
- docker
artifacts:
- "*.tar"
- step:
name: Deploy to Production
deployment: Production
script:
- echo ${DOCKERHUB_PASSWORD} | docker login --username "$DOCKERHUB_USERNAME" --password-stdin
- IMAGE_NAME=$BITBUCKET_REPO_SLUG
- docker load --input "${IMAGE_NAME}.tar"
- VERSION="prod-0.1.${BITBUCKET_BUILD_NUMBER}"
- IMAGE=${DOCKERHUB_NAMESPACE}/${IMAGE_NAME}
- docker tag "${IMAGE_NAME}" "${IMAGE}:${VERSION}"
- docker push "${IMAGE}:${VERSION}"
services:
- docker
```
When I push to my development branch, I get the following error:
unknown flag: --publish
See 'docker stop --help'.
Connection to ${IP} closed.
✖ Execution failed.
What am I missing/doing wrong here?
Can confirm this is working. Not sure why
- pipe: atlassian/ssh-run:0.2.2
variables:
SSH_USER: $SSH_USER
SERVER: $SSH_SERVER
COMMAND: >
docker stop $CONTAINERS_TO_STOP
docker run --publish $SERVER_PORT:$SERVER_PORT --detach $IMAGE_NAME
Any idea why this is not working?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.