Skip to content

Commit 195a1a6

Browse files
committed
Add building with docker-compose
1 parent 58ddc4a commit 195a1a6

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

Dockerfile

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
FROM golang:1.19-bullseye
1+
FROM golang:1.20-bullseye
22

3+
RUN mkdir -p $GOPATH/src/github.com/fly-apps/terraform-provider-fly
34
WORKDIR $GOPATH/src/github.com/fly-apps/terraform-provider-fly
4-
COPY go.mod .
5-
RUN go mod download -x
6-
RUN mkdir -p /out/
75

8-
COPY . .
9-
RUN go env; go install; cp $GOPATH/bin/terraform-provider-fly /out/
10-
11-
WORKDIR $GOPATH
6+
CMD go mod tidy; go build

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ To run acceptance tests for this provider some scaffolding is required.
3838
6. (Optional) set FLY_TF_TEST_REGION in `.make-overrides` to a region closer to you
3939

4040
### Building with Docker
41-
If you don't have a local Go environment, you can build in a container:
41+
If you do not have a local Go environment, you can build in a container. The binary will be placed in the root of the repository.
4242

43-
```
44-
docker build --pull -t provider-fly:latest .
45-
docker run --rm --entrypoint=cat provider-fly:latest /out/terraform-provider-fly > terraform-provider-fly
46-
```
43+
If you are not building for linux, set `GOOS` and `GOARCH` environment variables appropriately.
44+
45+
* `docker-compose up` (default, linux build)
46+
* `GOOS=darwin GOARCH=arm64 docker-compose up` (m1 mac)
47+
* `docker-compose up --build` if the version of golang has changed since the last run.

compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
services:
2+
build:
3+
build:
4+
context: .
5+
environment:
6+
- GOOS
7+
- GOARCH
8+
image: provider-fly
9+
volumes:
10+
- .:/go/src/github.com/fly-apps/terraform-provider-fly

0 commit comments

Comments
 (0)