Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMM-12899 Use module and build cache #2916

Draft
wants to merge 44 commits into
base: v3
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
1ef83f3
PMM-12899 Use module and build cache
ademidoff Mar 21, 2024
32c8fa8
PMM-12899 update grafana spec
ademidoff Mar 21, 2024
37e005a
PMM-12899 fix the build_command
ademidoff Mar 21, 2024
c863f50
PMM-12899 fix builddeps
ademidoff Mar 21, 2024
853be6e
PMM-12899 use rpmbuild:3
ademidoff Mar 21, 2024
d57ec55
PMM-12641 Fix the dashboard upgrade (#2926)
ademidoff Mar 26, 2024
5c7821f
PMM-12899 prevent grafana from using own GOPATH
ademidoff Mar 31, 2024
42a02a9
PMM-12899 use a dedicated folder for yarn cache
ademidoff Mar 31, 2024
6d0b02b
PMM-12899 extract server rpm script
ademidoff Apr 1, 2024
0a32c59
Merge branch 'v3' into PMM-12899-use-module-and-build-cache
ademidoff Apr 1, 2024
098e894
PMM-12899 fix server param evaluation
ademidoff Apr 1, 2024
c80fe45
Merge branch 'PMM-12899-use-module-and-build-cache' of github.com:per…
ademidoff Apr 1, 2024
aa5729f
PMM-12899 clean up server RPM specs
ademidoff Apr 1, 2024
aa5e8b8
PMM-12899 fix directory permissions
ademidoff Apr 1, 2024
ee45fd6
PMM-12899 remove unnecessary macro
ademidoff Apr 1, 2024
afde65a
PMM-12899 revert QAN package name
ademidoff Apr 1, 2024
f28cbcc
PMM-12899 merge update.sh to build.sh
ademidoff Apr 2, 2024
66dc390
Merge branch 'v3' into PMM-12899-use-module-and-build-cache
ademidoff Apr 2, 2024
093179a
PMM-12899 reorganize the script structure
ademidoff Apr 2, 2024
12fd453
PMM-12899 get rid of `exit 0` in callee scripts
ademidoff Apr 2, 2024
9587f21
PMM-12899 clean up pmm-update.spec
ademidoff Apr 2, 2024
13b4f65
PMM-12899 send exec time to the log file
ademidoff Apr 2, 2024
6f9eac8
PMM-12899 remove a redundant directory
ademidoff Apr 2, 2024
3eb50f8
PMM-12899 add total exec time
ademidoff Apr 2, 2024
36869b7
PMM-12899 reorg some variables
ademidoff Apr 2, 2024
bf640ca
PMM-12899 fix the regexp
ademidoff Apr 3, 2024
f28202a
PMM-12899 structure the code
ademidoff Apr 3, 2024
a0f7b50
PMM-12899 add a flag to skip building server docker
ademidoff Apr 3, 2024
988cfb0
PMM-12899 fix a failure of find when no files are found
ademidoff Apr 3, 2024
8216d65
Merge branch 'v3' into PMM-12899-use-module-and-build-cache
ademidoff Apr 3, 2024
d2c4ecb
Merge branch 'v3' into PMM-12899-use-module-and-build-cache
ademidoff Apr 6, 2024
0582998
PMM-12899 update the documentation
ademidoff Apr 10, 2024
0e0bde7
Merge branch 'v3' into PMM-12899-use-module-and-build-cache
ademidoff Apr 16, 2024
ccf3bf0
Merge branch 'v3' into PMM-12899-use-module-and-build-cache
ademidoff Jul 14, 2024
ea42fe7
PMM-12899 update README.md
ademidoff Oct 12, 2024
87cc6a2
Merge branch 'v3' into PMM-12899-use-module-and-build-cache
ademidoff Oct 12, 2024
fc248de
PMM-12899 fix duplicate labels in Dockerfile
ademidoff Oct 12, 2024
4b469bd
PMM-12899 add a config file for all PMM components
ademidoff Oct 14, 2024
6d590ce
Merge branch 'v3' into PMM-12899-use-module-and-build-cache
ademidoff Oct 19, 2024
f35a85f
PMM-12899 simplify init, add usage
ademidoff Oct 19, 2024
1aad3f7
PMM-12899 fix architecture for the client
ademidoff Oct 19, 2024
23aaaf6
PMM-12899 fix the build time for MacOS
ademidoff Oct 19, 2024
c2357c5
PMM-12899 fix git commit variable
ademidoff Oct 20, 2024
7925079
PMM-12899 don't use S3 cache for local builds
ademidoff Oct 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ jobs:
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_TOKEN_PMM_CI }}
SLACK_CHANNEL: "pmm-ci"
SLACK_USERNAME: "PR pipelines bot"
SLACK_ICON_EMOJI: ":chestnut:"
SLACK_USERNAME: "Build bot"
SLACK_ICON_EMOJI: ":octocat:"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I couldn't resist - :octocat: seems to be much more to the point here :)

SLACK_COLOR: "#00FF00"
SLACK_TITLE: "Finished ${{ github.event.repository.name }} workflow"
SLACK_MESSAGE: "${{ github.event.inputs.repo || github.repository }}:${{ github.event.inputs.branch || github.head_ref }}"
Expand All @@ -179,8 +179,8 @@ jobs:
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_TOKEN_PMM_CI }}
SLACK_CHANNEL: "pmm-ci"
SLACK_USERNAME: "PR pipelines bot"
SLACK_ICON_EMOJI: ":chestnut:"
SLACK_USERNAME: "Build bot"
SLACK_ICON_EMOJI: ":octocat:"
SLACK_COLOR: "#FF0000"
SLACK_TITLE: "Finished ${{ github.event.repository.name }} workflow"
SLACK_MESSAGE: "Workflow failed: ${{ github.event.inputs.repo || github.repository }}:${{ github.event.inputs.branch || github.head_ref }}"
Expand Down
18 changes: 10 additions & 8 deletions build/docker/client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@ RUN microdnf install shadow-utils jq tar -y
RUN groupadd -g 1002 pmm-agent && \
useradd -u 1002 -r -g pmm-agent -s /sbin/nologin \
-d /usr/local/percona/pmm \
-c "PMM 2.X Client User" pmm-agent
-c "PMM 3.x Client User" pmm-agent

FROM redhat/ubi9-micro

ARG VERSION
ARG BUILD_DATE

LABEL org.opencontainers.image.created ${BUILD_DATE}
LABEL org.opencontainers.image.licenses Apache-2.0
LABEL org.opencontainers.image.title Percona Monitoring and Management Client
LABEL org.opencontainers.image.vendor Percona
LABEL org.opencontainers.image.version ${VERSION}

COPY LICENSE /licenses/
COPY --from=users --chown=0:0 /etc/passwd /etc/passwd
COPY --from=users --chown=0:0 /etc/group /etc/group
Expand Down Expand Up @@ -49,10 +43,18 @@ RUN install -d -o pmm-agent -g pmm-agent -m 0775 /usr/local/percona/pmm
ADD pmm-client.tar.gz /tmp/

RUN cd /tmp/pmm-client-* \
&& env PMM_USER=pmm-agent PMM_GROUP=root ./install_tarball \
&& PMM_USER=pmm-agent PMM_GROUP=root ./install_tarball \
&& cd /tmp \
&& rm -rf /tmp/pmm-client*

LABEL org.opencontainers.image.created ${BUILD_DATE}
LABEL org.opencontainers.image.licenses Apache-2.0
LABEL org.opencontainers.image.title Percona Monitoring and Management Client
LABEL org.opencontainers.image.vendor Percona
LABEL org.opencontainers.image.version ${VERSION}
LABEL org.opencontainers.image.source https://github.com/percona/pmm/blob/main/build/docker/client/Dockerfile
LABEL org.opencontainers.image.docs https://docs.percona.com/percona-monitoring-and-management/setting-up/client/index.html#docker

USER pmm-agent
WORKDIR /usr/local/percona/pmm/
ENV PATH /usr/local/percona/pmm/bin/:$PATH
Expand Down
2 changes: 2 additions & 0 deletions build/docker/server/Dockerfile.el9
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ LABEL org.opencontainers.image.licenses AGPL-3.0
LABEL org.opencontainers.image.title Percona Monitoring and Management
LABEL org.opencontainers.image.vendor Percona LLC
LABEL org.opencontainers.image.version ${VERSION}
LABEL org.opencontainers.image.source https://github.com/percona/pmm/blob/main/build/docker/server/Dockerfile.el9
LABEL org.opencontainers.image.docs https://docs.percona.com/percona-monitoring-and-management/setting-up/server/docker.html

USER pmm

Expand Down
29 changes: 0 additions & 29 deletions build/docker/server/create_users.sh

This file was deleted.

77 changes: 77 additions & 0 deletions build/local/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Local builds

This directory contains a set of scripts aimed at providing a simple way to build PMM locally.

## Background

Historically, PMM used to be built using Jenkins. This worked well for the team, but not for the community. The learning curve was, and still is, rather steep, and it is hard for folks, even internally, to contribute to.

Therefore, we decided to make it possible to build PMM locally. This is a work in progress, but we are definitely committed to bring the developer experience to an acceptable level.

The build process is mostly based on bash scripts, which control the build flow. This was an intentional decision early on, since every developer should have at least a basic command of bash. Apart from bash and a few other well-known utilitites like `curl` or `make`, it also uses Docker for environment isolation and caching.

The build process is designed to run on a Linux host. We believe it can run on other flavors of Linux, including MacOS, with little to no modification (TBC).


## Prerequisites

Below is a list of prerequisites that are required to build PMM locally.

- OS: Linux (tested on Oracle Linux 9.3, CentOS 7, Ubuntu 22.04.3 LTS)
- Docker: 25.0.2+ (tested on 25.0.2)
- Docker Compose Plugin: 2.24.7+ (tested on 2.24.7)
- make: 4.3+ (tested on 4.3)
- bash (GNU): 5.1+ (tested on 5.1)
- git: 2.34.1+ (tested on 2.34.1)
- curl: 7.81.0+ (tested on 7.81.0)
- yq: 4.42.0+ (tested on 4.42.1)
- jq: 1.6+ (tested on 1.6)


## How to build PMM

1. Install the prerequisites
2. Clone the PMM repository to the user's home directory, e.g.: `git clone https://github.com/percona/pmm /home/user/pmm`.
3. Change to the `build/local` directory in the cloned repo.
4. Run `build.sh --help` to print the help message and check the usage.
5. Run `build.sh` with parameters of your choice to build PMM v3.

Usually, you will want to rebuild PMM whenever there are changes in at least one of its components. All components of PMM are gathered together in one repository - `github.com/percona-lab/pmm-submodules` (or `pmm-submodules`). Therefore, you can run `build.sh` as often as those changes need to be factored in to the next build.

Once the build is finished, you can proceed with launching a new instance of PMM Server, or installing a freshly built PMM Client, and testing the changes.


## The `rpmbuild` image and docker cache

We use a special docker image to build various PMM artifacts - `perconalab/rpmbuild:3`. It comes provisioned with tools which are required to build PMM artifacts, for example RPM packages. As a build tool, it offers a number of benefits, two most obvious of which are:

- it frees the user from installing dependencies on their host machine
- it leverages a very powerful docker caching system, which results in reduced build times

During the first run, `build.sh` will create a few directories on the host machine, which are necessary to make use of docker cache. Please be aware, that the docker container's user needs to be able to write to these directories. The docker container's user is `builder` with uid 1000 and gid 1000. You need to make sure that the directories we create on the host are owned by a user with the same uid and gid. If the build fails, this is the first thing to check.


## Avoiding unnecessary builds

Sometimes, the changes you make affect only PMM Client. Other times, they affect only PMM Server. Therefore, you may want to skip building parts of PMM. The `build.sh` script offers several parameters to help control what you want to build.

* --no-update: run the build tasks without pulling the changes from `pmm-submodules` repository
* --update-only: pull changes from the repo without building PMM
* --no-client: do not build the client, use the cached PMM Client artifacts
* --no-client-docker: skip building PMM Client docker container
* --no-server-rpm: skip building PMM Server RPM artifacts
* --log-file <path>: change the path of the build log file

It's important to note, however, that once all changes are made and tested, you most probably want to re-build both PMM Client and Server to test them together.


## Target environments

Currently, local builds target the following environments:
- PMM Client
- tarball - virtually any amd64 Linux environment
- RPM - RHEL9-compatible environments
- docker image - docker and Kubernetes environments (amd64)
- PMM Server
- docker image - docker and Kubernetes environments (amd64)

Loading
Loading