Skip to content

Commit 2c339bd

Browse files
committed
Add hack/Dockerfile, drop COREOS_ASSEMBLER_GIT
With the move to using even more Go, the workflow of just bind mounting the source code will break more and more. (It has never worked for anything in mantle/) Let's document a more robust workflow that ensures that the Go code is recompiled.
1 parent 388f8d3 commit 2c339bd

File tree

6 files changed

+22
-17
lines changed

6 files changed

+22
-17
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# kola_temp can include socket files that the build process does not like
22
/mantle/_kola_temp
3+
/bin

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ else ifeq ($(GOARCH),aarch64)
3131
endif
3232

3333
bin/coreos-assembler:
34-
cd cmd && go build -mod vendor -o ../$@
34+
cd cmd && go build $(GOFLAGS) -mod vendor -o ../$@
3535
.PHONY: bin/coreos-assembler
3636

3737
.%.shellchecked: %

docs/building-fcos.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ cosa() {
101101
-v ${PWD}:/srv/ --device /dev/kvm --device /dev/fuse \
102102
--tmpfs /tmp -v /var/tmp:/var/tmp --name cosa \
103103
${COREOS_ASSEMBLER_CONFIG_GIT:+-v $COREOS_ASSEMBLER_CONFIG_GIT:/srv/src/config/:ro} \
104-
${COREOS_ASSEMBLER_GIT:+-v $COREOS_ASSEMBLER_GIT/src/:/usr/lib/coreos-assembler/:ro} \
105104
${COREOS_ASSEMBLER_CONTAINER_RUNTIME_ARGS} \
106105
${COREOS_ASSEMBLER_CONTAINER:-$COREOS_ASSEMBLER_CONTAINER_LATEST} "$@"
107106
rc=$?; set +x; return $rc
@@ -127,9 +126,6 @@ The environment variables are special purpose:
127126

128127
- `COREOS_ASSEMBLER_CONFIG_GIT`: Allows you to specifiy a local directory that
129128
contains the configs for the ostree you are trying to compose.
130-
- `COREOS_ASSEMBLER_GIT`: Allows you to specify a local directory that contains
131-
the CoreOS Assembler scripts. This allows for quick hacking on the assembler
132-
itself.
133129
- `COREOS_ASSEMBLER_CONTAINER_RUNTIME_ARGS`: Allows for adding arbitrary mounts
134130
or args to the container runtime.
135131
- `COREOS_ASSEMBLER_CONTAINER`: Allows for overriding the default assembler

docs/devel.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ guides if you are looking for how to use the CoreOS Assembler.
1212
1. TOC
1313
{:toc}
1414

15-
## Hacking on CoreOS Assembler Scripts
15+
## Hacking on CoreOS Assembler
1616

17-
If you find yourself wanting to hack on CoreOS Assembler itself then you can
18-
easily mount the scripts into the container and prevent rebuilding the
19-
container to test every change. This can be done using the
20-
`COREOS_ASSEMBLER_GIT` env var.
17+
You could rerun `podman build -t localhost/cosa` every time you make
18+
a change, but it'd be very expensive to do so.
2119

22-
```
23-
$ export COREOS_ASSEMBLER_GIT=/path/to/github.com/coreos/coreos-assembler/
24-
$ cosa init https://github.com/coreos/fedora-coreos-config.git
25-
$ cosa fetch && cosa build
26-
```
20+
Instead, you can use [hack/Dockerfile]. There are instructions in that
21+
file. This avoids redownloading and reinstalling all of the
22+
dependency RPMs.
23+
24+
For even faster workflow, you can just bind mount in binaries from
25+
your host or from another container by adding additional bind mounts,
26+
and then copy files into your coreos-assembler container more manually.
2727

2828
## Installing cosa inside an existing container
2929

hack/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Use this for quicker iteration on coros-assembler; from the toplevel run e.g.:
2+
# podman build -t localhost/cosa -f hack/Dockerfile .
3+
FROM quay.io/coreos-assembler/coreos-assembler:latest
4+
WORKDIR /src
5+
COPY . .
6+
USER root
7+
RUN env GOFLAGS="-buildvcs=false" make && make install
8+
USER builder

mantle/build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ ldflags="-X ${REPO_PATH}/version.Version=${version}"
2626
host_build() {
2727
local cmd=$1; shift
2828
echo "Building $cmd"
29-
go build \
29+
go build ${GOFLAGS:-} \
3030
-ldflags "${ldflags}" \
3131
-mod vendor \
3232
-o "bin/$cmd" \
@@ -41,7 +41,7 @@ cross_static_build() {
4141
mkdir -p "bin/$a"
4242
echo "Building $a/$cmd (static)"
4343
CGO_ENABLED=0 GOARCH=${BASEARCH_TO_GOARCH[$a]} \
44-
go build \
44+
go build ${GOFLAGS:-} \
4545
-ldflags "${ldflags} -extldflags=-static" \
4646
-mod vendor \
4747
-o "bin/$a/$cmd" \

0 commit comments

Comments
 (0)