I have managed to get pipelines to build a docker image (using a local dockerfile) and have saved it as an artifact.
I want to have the a step run a container from the local image and execute some commands in it that test the app that it hosts. Below is a rough guess at how this might be set up in pipelines, but I'm wondering if pipelines requires the image to come from a registry.
From what Ive read I also need to define the config of the mysql service in a preceding definitions section too, I'm just excluding it below.
Can anyone point me in the right direction?
The goal is to have the app in the container tested while it has access to a mysql db, after which it can be deployed.
Thanks for reading.
pipelines:
branches:
development:
- step:
name: build image
services:
- docker
caches:
- docker
script:
- docker build -t image-name .
- docker save --output tmp-image.docker image-name
artifacts:
- tmp-image.docker
- step:
name: run image
image: ./tmp-image.docker
services:
- mysql
script:
- npm run test
edit:
I also tried uploading the image to AWS ECR and get an error because the error i get when the pipeline runs is:
There is a problem with the format of your docker image name at [pipelines > branches > develop > 2 > step > image > name].
I tried the format listed here:
https://support.atlassian.com/bitbucket-cloud/docs/use-docker-images-as-build-environments/#Private-images-hosted-by-AWS-ECR--EC2-Container-Registry-
this is what I have for the run step:
- step:
name: RUN IMAGE
image:
name: ${AWS_DEV_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/name-of-ecr-repository:${BITBUCKET_BRANCH}_${BITBUCKET_COMMIT:0:7}
aws:
access-key: $AWS_ACCESS_KEY
secret-key: $AWS_SECRET_KEY
services:
- docker
- mysql
script:
- source set.env
- npm run test
and I get the same error... maybe you cant use variables in the image name?
edit#2:
figured out the last issue, it was typo.
Now I'm getting a 403 forbidden from ECR... the journey continues.
edit3:
I fixed the ecr pull 403 error and now the next step (where I try to run the container) fails with no error output at all.
I took the bitbucket pipelines course and I want my $40 back. The databases/services coverage is 8 minutes and doesn't even include a mysql example. In fact there's no example code provided anywhere as far as I can see, not even in the student guide pdf.