I'm using Bitbucket Pipelines and I have a question about it.
I want to build my repository on Ubuntu 20.04. The essential tools I need are as follows:
I am currently installing all the software each time I build using the following command:
This is inefficient.
I want to know how to cache the tools I've installed once. How should I write my bitbucket-pipelines.yml?
Below is part of my yml file
image: atlassian/default-image:latest pipelines: default: - step: name: Build on Ubuntu 20.04 image: ubuntu:20.04 script: - apt-get update && apt-get install -y gcc-9 g++-9 cmake openjdk-8-jdk openjdk-17-jre openjdk-17-jdk ant
Hi @홍창기 and welcome to the community!
The recommended approach for your use case is to create a custom Docker image with the tools you need and use that as a build environment instead of ubuntu:20.04.
If you install Docker on your computer, you can build an image from a Dockerfile like the following:
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y gcc-9 g++-9 cmake openjdk-8-jdk openjdk-17-jre openjdk-17-jdk ant
You can then create an account and a repo in Dockerhub and push the image you build to this repo. If the repo's name is e.g. myaccount/myimage:latest, then you can use that in your yml file's step instead of ubuntu:20.04.
It is not necessary to use Dockerhub, you could also use another Docker registry. We support public and private Docker images including those hosted on Docker Hub, AWS, GCP, Azure, and self-hosted registries accessible on the internet.
You can find more details here:
There is a section with the title Creating a custom build environment near the end of this page with more resources.
Please feel free to reach out if you have any questions.
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are very welcome @홍창기, please feel free to let me know if you encounter any issues.
Have a nice day too!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It is possible to cache Docker images and many other artifacts:
https://support.atlassian.com/bitbucket-cloud/docs/cache-dependencies/
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.