Skip to content

Commit

Permalink
add docker-image workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiwara committed May 21, 2024
1 parent 03c5e38 commit a7e01c3
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 1 deletion.
34 changes: 34 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: docker-image
on:
workflow_dispatch:

permissions:
pull-requests: write
packages: write
contents: write
actions: write

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: $GITHUB_ACTOR
password: ${{ secrets.GITHUB_TOKEN }}

- name: docker
run: |
make docker-build-push-all
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ FROM golang:1.22.3-bookworm AS builder
WORKDIR /app
RUN git clone https://github.com/fujiwara/aws-sdk-client-go.git .
RUN rm -f gen.yaml

ENTRYPOINT ["./build-in-docker.sh"]
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,11 @@ test:

packages:
goreleaser build --skip=validate --clean

docker-build-and-push: Dockerfile
docker buildx build \
--platform=linux/amd64,linux/arm64 \
-t ghcr.io/fujiwara/aws-sdk-client-go:builder \
-f Dockerfile \
--push \
.
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ services:

Keys of `services` are AWS service names (`github.com/aws/aws-sdk-go-v2/service/*`), and values are method names of the service client (for example, `s3` is [s3.Client](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/s3#Client)). If you don't specify the method names, all methods of the service client are generated.

### Build the client
### Build on your machine

To build the client, run the following commands (or simply run `make`):

Expand All @@ -71,6 +71,34 @@ $ go build -o your-client ./cmd/aws-sdk-client-go/main.go

If you change the configuration, run `make clean` before `make` to purge the generated files.

### Build with Docker

`ghcr.io/fujiwara/aws-sdk-client-go:builder` is a Docker image that contains the Go environment. You can build the client in the container.

Environment variables:
- `GIT_REF`: Git reference to checkout the repository. Default is `main`. You can specify a branch, tag, or commit hash.

Example of use `AWS_SDK_CLIENT_GO_GEN` environment variable:
```console
$ docker run -it -e AWS_SDK_CLIENT_GO_GEN=ecs,firehose,s3 ghcr.io/fujiwara/aws-sdk-client-go:builder
...
```

Example of `gen.yaml` configuration file:
```console
$ docker run -it -v $(pwd)/gen.yaml:/app/gen.yaml ghcr.io/fujiwara/aws-sdk-client-go:builder
...
Completed. Please extract /app/aws-sdk-client-go from this container!
For example, run the following command:
docker cp $(docker ps -lq):/app/aws-sdk-client-go .
```

After the build is completed, the built binary is in the container. You can copy it to your host machine with `docker cp` command.

```console
$ docker cp $(docker ps -lq):/app/aws-sdk-client-go .
```

## Performance comparison

Example of execution `sts get-caller-identity` on 0.25vCPU Fargate(AMD64).
Expand Down

0 comments on commit a7e01c3

Please sign in to comment.