summaryrefslogtreecommitdiff
path: root/build
AgeCommit message (Collapse)AuthorFilesLines
2018-10-01Remove support for `sharedvolume` configurationDan Duvall2-19/+0
Support for mounting a shared volume instead of copying application files was meant to provide an option for development use cases. This functionality has never been thoroughly tested or utilized for any use case. It should be removed for now. Relates tangentially to task T204591 that simplifies node support. Change-Id: Ib70cb7bceb504841897a38d732880ba376fe67c8
2018-08-14Refactor builder to support file requirements and run pre-installDan Duvall2-1/+143
The builder configuration has proven useful for supporting generic pre-entrypoint commands such as dependency managers not otherwise supported by specific Blubber configuration. Adding additional `builder.requirements` config expands support for such commands by allowing the user to specify files that should be copied into the image before the builder command runs. To support this extra configuration, `builder` had to be changed from a simple string to a mapping. The builder command must now by given as `builder.command`. The pattern of creating parent directories, copying files, and executing one or more commands prior to the entrypoint has become a common one. Some of the implementation of this pattern was moved from `PythonConfig` into shared build macros `build.SortFilesByDir` and `build.SyncFiles`. All config types that must have requirements files copied over independently of the entire source tree (`PythonConfig`, `BuilderConfig`, `NodeConfig`) now delegate to these functions. Change-Id: I67f33034f22cee2851ec866cfb07ab20c23eba8c
2018-07-31Change import paths from Phabricator to GerritDan Duvall2-2/+2
All import paths and other references to the previously Blubber repo in Phabricator have been changed to point to the new Gerrit project URL. Note that building or testing against this change will require you to move your working directory to `$GOPATH/src/gerrit.wikimedia.org/r/blubber`. Contribution documentation was updated to reflect the changes, and the `.arcvendor` submodule has been removed. Bug: T200452 Change-Id: I3ab23e420b2825e86e2bd7c9b3da9d4de23edaa1
2018-07-26Add slash to directory path if copying > 1 fileTyler Cipriani2-5/+13
Summary: Ran into a Docker error when attempting to build a node project with more than one requirements files: When using COPY with more than one source file, the destination must be a directory and end with a / Reviewers: dduvall, #release-engineering-team Reviewed By: dduvall, #release-engineering-team Tags: #release-engineering-team Differential Revision: https://phabricator.wikimedia.org/D1080
2018-03-22Fix ownership on artifact copiesDan Duvall4-8/+30
Summary: The implementation of D984 did not include enforcing ownership for `build.CopyFrom` instruction and so artifacts copied from one image to another via `copies:` were problematically owned as root. In order to fix this behavior: 1. `config.ArtifactConfig` `build.CopyFrom` instructions are now injected duration `build.PhaseInstall` 2. `config.VariantConfig` calls `build.ApplyUser` for these artifact instructions as well using the `runs.as` user 3. `build.CopyAs` was refactored to wrap any `build.Instruction` which should only really be used with `build.Copy` or `build.CopyFrom`. Test Plan: Run `go test ./...`. Run `blubber` against configuration with a variant that uses `copies` and verify that the `COPY --from` instructions also include a `--chown` flag. Reviewers: thcipriani, mmodell, hashar, #release-engineering-team, demon Reviewed By: thcipriani, #release-engineering-team Tags: #release-engineering-team Differential Revision: https://phabricator.wikimedia.org/D1002
2018-03-05Generalize instructions for entrypoint and working directoryDan Duvall3-0/+49
Summary: Introduce new `build.EntryPoint` and `build.WorkingDirectory` instructions to allow configuration to inject them instead of hard coding their generation in the Docker compiler. Simplified the Docker compiler to simply iterate over build phases as returned by a new function `build.Phases()`. Depends on D990 Test Plan: Run `go test ./...`. Reviewers: thcipriani, demon, hashar, #release-engineering-team Reviewed By: thcipriani, #release-engineering-team Tags: #release-engineering-team Differential Revision: https://phabricator.wikimedia.org/D991
2018-03-05Fix application files/runtime permissions schemeDan Duvall4-0/+162
Summary: Introduces new `lives` configuration that provides the name/UID/GID of the user that will own application files and installed dependencies. This new configuration is distinct from `runs` in that the former determines application file location ownership and the latter now only determines runtime process ownership. Default configuration has also been introduced for both config sections. In addition to the new configuration, a new `build.CopyAs` instruction has been introduced that ensures correct UID/GID ownership of files copied into the container image, and all unqualified `build.Copy` instructions are wrapped by the new `build.CopyAs` instruction using the UID/GID appropriate for the current build phase. A new `build.User` instruction is also introduced and injected into the build at the start of certain phases to enforce ownership of `build.Run` processes. This effective process/file ownership model is: PhasePrivileged - "root" PhasePrivilegedDropped - lives.as PhasePreInstall - lives.as PhaseInstall - lives.as PhasePostInstall - runs.as Fixes T187372 Test Plan: Run `go test ./...`. Reviewers: thcipriani, hashar, demon, #release-engineering-team Reviewed By: thcipriani, #release-engineering-team Subscribers: mmodell Tags: #release-engineering-team Maniphest Tasks: T187372 Differential Revision: https://phabricator.wikimedia.org/D984
2017-11-06Documented all exported types, functions, and interfacesDan Duvall2-17/+74
Summary: Wrote inline documentation for all the things. Fixes T168000 Test Plan: Execute `godoc -http=:6060` and proofread all the things. Reviewers: thcipriani, hashar, #release-engineering-team, demon Reviewed By: thcipriani, #release-engineering-team, demon Tags: #release-engineering-team Maniphest Tasks: T168000 Differential Revision: https://phabricator.wikimedia.org/D841
2017-10-19Include meta data as labels in Dockerfile outputDan Duvall2-12/+41
Summary: Certain meta data including the Blubber version and variant used at invocation may be useful in downstream tracking. Implemented abstract and Docker-specific instructions for labels and modified the Docker compiler to include these instructions at the end of the output for the final stage. Depends on D816 Fixes T178022 Test Plan: Run unit tests. Run `make && bin/blubber blubber.example.yaml production` and verify that both `blubber.version` and `blubber.variant` labels are present and accurate. Reviewers: thcipriani, hashar, #release-engineering-team Reviewed By: thcipriani, #release-engineering-team Tags: #release-engineering-team Maniphest Tasks: T178022 Differential Revision: https://phabricator.wikimedia.org/D818
2017-09-14Switch to github import path for testifyDan Duvall1-1/+1
Summary: Debian only provides a package for the GitHub version so it's either this or we'd have to maintain a patch to change the import paths at packaging, a moving target for sure. Since it's only a development dependency, we're not too worried about versioning it and this is a much more simple solution. Refs T175609 Test Plan: Run `go get ./... && go test ./...`. Reviewers: thcipriani, #release-engineering-team Reviewed By: thcipriani, #release-engineering-team Tags: #release-engineering-team Maniphest Tasks: T175609 Differential Revision: https://phabricator.wikimedia.org/D782
2017-09-14Use import paths without `.git` suffixDan Duvall1-1/+1
Summary: Now that our Phabricator instance handles `go get` requests, we can use a path without the `.git` suffix as the canonical import path. Test Plan: Run `go test ./...` and `go build`. Reviewers: thcipriani, #release-engineering-team Reviewed By: thcipriani, #release-engineering-team Tags: #release-engineering-team Differential Revision: https://phabricator.wikimedia.org/D780
2017-09-07Smarter copies/sharedvolume/default behaviorDan Duvall3-0/+15
Summary: Defined new abstract `build.Volume` and corresponding `docker.DockerVolume` instructions. Refactored compilation of main `COPY` or `VOLUME` instruction for application files to use the new instructions and moved injection of these instructions out of the compiler and into `VariantConfig`. The latter can be smarter about the following cases: 1. When `copies` is set, simply depend on artifacts for the application files and do not copy anything from the build host. 2. When `sharedvolume` is `true`, inject a `build.Volume` instruction for the application working directory. 3. When neither of the above are set, copy application files from the host. Fixes T174623 Depends on D768 Test Plan: Run `go test ./...`. Run `blubber blubber.example.yaml production` and ensure: 1. The `prep` stage has a `COPY . .` instruction. 2. The final stage has no `COPY . .` instruction, only `COPY --from=prep` instructions. Reviewers: thcipriani, mobrovac, hashar, mmodell, #release-engineering-team Reviewed By: thcipriani, mobrovac, #release-engineering-team Tags: #release-engineering-team Maniphest Tasks: T174623 Differential Revision: https://phabricator.wikimedia.org/D769
2017-09-07Support `copies` config entry for multi-stage buildsDan Duvall2-0/+15
Summary: Support a `copies` variant config entry that will result in a multi-stage build, copying both shared library files and application directory from a previously defined variant. This is essentially a shorthand for two `artifacts` entries that are likely to be idiomatic to multi-stage build/prod configurations. Defined a new abstract `build.CopyFrom` instruction and corresponding `docker.DockerCopyFrom` instruction and refactored the writing of these Dockerfile lines to be accomplished using an `InstructionsForPhase` method on `config.ArtifactsConfig`. Implemented new support for `copies` configuration in `config.VariantConfig` and an `InstructionsForPhase` method that returns `build.CopyFrom` instructions for both the shared library and application directories. Fixes T174622 Depends on D759 Test Plan: Run `go test ./...`. Run `blubber blubber.example.yaml production` and ensure the right `COPY --from` lines are included for the final stage. Reviewers: thcipriani, mobrovac, hashar, mmodell, #release-engineering-team Reviewed By: thcipriani, #release-engineering-team Tags: #release-engineering-team Maniphest Tasks: T174622 Differential Revision: https://phabricator.wikimedia.org/D768
2017-08-30Use real types for build instructionsDan Duvall2-8/+141
Summary: Refactored build instructions to use concrete types and `build.Instruction` as an interface instead of relying on a simple enum and arbitrary string arguments. The formal types result in: 1. Clearer internal data structures 2. Partial compilation and proper argument quoting for all instructions moved into the common `build` package 3. Higher order instructions like `build.RunAll` that easily reduce to compiler specific output Test Plan: Run `arc unit` or `go test ./...` Reviewers: thcipriani, mmodell, #release-engineering-team Reviewed By: thcipriani, #release-engineering-team Tags: #release-engineering-team Differential Revision: https://phabricator.wikimedia.org/D741
2017-06-29Run go fmtTyler Cipriani1-1/+1
Summary: One of Golang's "advantages" is not quibbling over style. To this end the `go fmt` command exists. This is the result of me running: find . -name '*.go' -exec go fmt {} \; Test Plan: built package, ran tests Reviewers: dduvall, mmodell, #release-engineering-team Reviewed By: dduvall, mmodell, #release-engineering-team Subscribers: hashar Tags: #release-engineering-team Differential Revision: https://phabricator.wikimedia.org/D694
2017-06-20Set HOME environment variable for runs-as userDan Duvall1-0/+1
Summary: Fixes build issues around home permissions by setting `HOME` to the unprivileged user's home directory once the "privileges dropped" build phase has been reached. Test Plan: Run `go test ./...`. Reviewers: thcipriani, mobrovac, hashar, Jrbranaa, mmodell, #release-engineering-team Reviewed By: mobrovac Tags: #release-engineering-team Differential Revision: https://phabricator.wikimedia.org/D686
2017-05-10Decouple Docker compiler from apt/npm providersDan Duvall2-0/+27
Establish phases within Docker compiler to allow providers (apt, npm, etc.) to inject their own run/copy instructions into to the Dockerfile compilation process while leaving the compiler agnostic to the providers themselves. The instructions and phases are also generalized to leave room for alternative compilers should they be needed in the future (e.g. aci support via acbuild) but also as a general design constraint to leave compiler implementation concerns out of providers.