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.