build-image/README.md

83 lines
2.3 KiB
Markdown
Raw Permalink Normal View History

# build-image
2020-06-06 15:24:05 +00:00
[![Build Status](https://drone.cryptic.systems/api/badges/volker.raschek/build-image/status.svg)](https://drone.cryptic.systems/volker.raschek/build-image)
[![Docker Pulls](https://img.shields.io/docker/pulls/volkerraschek/build-image)](https://hub.docker.com/r/volkerraschek/build-image)
2019-08-19 16:28:06 +00:00
2024-04-19 20:03:59 +00:00
This project contains all sources to build the container image `docker.io/volkerraschek/build-image`. The primary goal
of the image is only to provide an environment to compile source code for `go` or `rust` and package compiled binaries
as PKG for Arch Linux or as RPM for RHEL based distributions.
2022-04-02 14:33:40 +00:00
## Supported environment variables
### gnupg
#### GNUPG_KEY
2024-04-19 20:03:59 +00:00
Import private gpg key via `GPG_KEY`. The private key must be escaped to import the key inside the container image
correctly. For example:
2022-04-02 14:33:40 +00:00
```bash
GPG_FPR=YOUR_GPG_FINGERPRINT
GPG_KEY=$(gpg --armor --export-secret-keys ${GPG_FPR} | cat -e | sed -e 's/\$/\\n/g' -e 's/^[ \t]*//g')
```
### makepkg
2024-04-19 20:03:59 +00:00
The `makepkg.conf` configuration is composed from the environment variables with the prefix `MAKEPKG_`. Below are some
examples:
2022-04-02 14:33:40 +00:00
`MAKEPKG_PACKAGER="Hugo McKinnock <hugo.mckinnock@example.local>"`
`MAKEPKG_GPGKEY="0123456789"`
`MAKEPKG_PKGEXT=.pkg.tar.zst"`
### ssh
#### SSH_KEY
2024-04-19 20:03:59 +00:00
Import private ssh key via `SSH_KEY`. The private key must be escaped to import the key inside the container image
correctly. For example:
2022-04-02 14:33:40 +00:00
```bash
SSH_KEY=$(cat -e ${HOME}/.ssh/id_rsa | sed -e 's/\$/\\n/g')
```
2019-04-18 17:11:26 +00:00
2019-09-13 15:58:20 +00:00
## Usage
### golang
2019-08-19 16:28:06 +00:00
2024-04-19 20:03:59 +00:00
To use this image for building golang applications execute this in your root folder of your go project.
2019-08-19 16:28:06 +00:00
2019-04-18 17:11:26 +00:00
```bash
$ docker run \
--rm \
--volume ${PWD}:/workspace \
volkerraschek/build-image:latest \
go build
2019-08-19 16:28:06 +00:00
```
2022-04-02 14:33:40 +00:00
### makepkg
2024-04-19 20:03:59 +00:00
With the following example will be an package be build for Arch Linux. Execute the commond in the root directory of the
project, where the `PKGBUILD` file is located.
2022-04-02 14:33:40 +00:00
```bash
$ docker run \
--env MAKEPKG_PACKAGER="Max Mustermann <max.mustermann@example.com" \
--rm \
--volume ${PWD}:/workspace \
volkerraschek/build-image:latest \
makepkg
```
2019-09-13 15:58:20 +00:00
### rust
2019-08-19 16:28:06 +00:00
2024-04-19 20:03:59 +00:00
If you want to compile instead go rust sourcecode, than you can do it similar to the golang example.
2019-08-19 16:28:06 +00:00
```bash
$ docker run \
--rm \
--volume ${PWD}:/workspace \
volkerraschek/build-image:latest \
cargo build --release
```