Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
Add building with docker-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
zxaos committed Jun 22, 2023
1 parent 58ddc4a commit 195a1a6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
11 changes: 3 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
FROM golang:1.19-bullseye
FROM golang:1.20-bullseye

RUN mkdir -p $GOPATH/src/github.com/fly-apps/terraform-provider-fly
WORKDIR $GOPATH/src/github.com/fly-apps/terraform-provider-fly
COPY go.mod .
RUN go mod download -x
RUN mkdir -p /out/

COPY . .
RUN go env; go install; cp $GOPATH/bin/terraform-provider-fly /out/

WORKDIR $GOPATH
CMD go mod tidy; go build
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ To run acceptance tests for this provider some scaffolding is required.
6. (Optional) set FLY_TF_TEST_REGION in `.make-overrides` to a region closer to you

### Building with Docker
If you don't have a local Go environment, you can build in a container:
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.

```
docker build --pull -t provider-fly:latest .
docker run --rm --entrypoint=cat provider-fly:latest /out/terraform-provider-fly > terraform-provider-fly
```
If you are not building for linux, set `GOOS` and `GOARCH` environment variables appropriately.

* `docker-compose up` (default, linux build)
* `GOOS=darwin GOARCH=arm64 docker-compose up` (m1 mac)
* `docker-compose up --build` if the version of golang has changed since the last run.
10 changes: 10 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
build:
build:
context: .
environment:
- GOOS
- GOARCH
image: provider-fly
volumes:
- .:/go/src/github.com/fly-apps/terraform-provider-fly

0 comments on commit 195a1a6

Please sign in to comment.