Skip to content

Commit

Permalink
Merge pull request #144 from dokku/master
Browse files Browse the repository at this point in the history
Release 0.6.0
  • Loading branch information
josegonzalez authored Feb 8, 2024
2 parents 6a40360 + 91ff4c4 commit 1270aad
Show file tree
Hide file tree
Showing 13 changed files with 206 additions and 221 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: make version
run: |
make version .env.docker
Expand All @@ -29,7 +29,7 @@ jobs:
- run: make build-in-docker
- run: make validate-in-docker
- name: upload packages
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: build
path: build/**/*
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
22 changes: 11 additions & 11 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ on:
jobs:
hadolint:
name: hadolint
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Run hadolint
uses: hadolint/hadolint-action@54c9adbab1582c2ef04b2016b760714a4bfde3cf
# v1.5.0 => c27bd9edc1e95eed30474db8f295ff5807ebca14

markdown-lint:
name: markdown-lint
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Run markdown-lint
uses: avto-dev/markdown-lint@04d43ee9191307b50935a753da3b775ab695eceb
# v1.5.0 => 04d43ee9191307b50935a753da3b775ab695eceb
Expand All @@ -36,23 +36,23 @@ jobs:

shellcheck:
name: shellcheck
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Run shellcheck
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38
# 1.1.0 => 94e0aab03ca135d11a35e5bfc14e6746dc56e7e9
env:
SHELLCHECK_OPTS: -s bash
shfmt:
name: shfmt
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Run shfmt
uses: luizm/action-sh-checker@76ab0b22e1f194e4a582edc7969df6485c4e9246
uses: luizm/action-sh-checker@c6edb3de93e904488b413636d96c6a56e3ad671a
# v0.3.0 => 7f44869033b40ee4ffe7dc76c87a1bc66e3d025a
env:
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
Expand All @@ -63,10 +63,10 @@ jobs:

yamllint:
name: yamllint
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Clone
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Run yamllint
uses: ibiqlik/action-yamllint@2576378a8e339169678f9939646ee3ee325e845c
# v3.0.2 => c19bd0523a9011c3a3960fe6640a0882b59af15d
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20.5-buster
FROM golang:1.22.0-bookworm

# hadolint ignore=DL3027
RUN apt-get update \
Expand All @@ -9,7 +9,7 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*

# hadolint ignore=DL3028
RUN gem install --no-ri --no-rdoc --quiet rake fpm package_cloud
RUN gem install --quiet rake fpm package_cloud

WORKDIR /src

Expand Down
45 changes: 2 additions & 43 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ MAINTAINER_NAME = Jose Diaz-Gonzalez
REPOSITORY = lambda-builder
HARDWARE = $(shell uname -m)
SYSTEM_NAME = $(shell uname -s | tr '[:upper:]' '[:lower:]')
BASE_VERSION ?= 0.5.0
BASE_VERSION ?= 0.6.0
IMAGE_NAME ?= $(MAINTAINER)/$(REPOSITORY)
PACKAGECLOUD_REPOSITORY ?= dokku/dokku-betafish

Expand Down Expand Up @@ -46,10 +46,8 @@ build: prebuild
@$(MAKE) build/darwin/$(NAME)-arm64
@$(MAKE) build/linux/$(NAME)-amd64
@$(MAKE) build/linux/$(NAME)-arm64
@$(MAKE) build/linux/$(NAME)-armhf
@$(MAKE) build/deb/$(NAME)_$(VERSION)_amd64.deb
@$(MAKE) build/deb/$(NAME)_$(VERSION)_arm64.deb
@$(MAKE) build/deb/$(NAME)_$(VERSION)_armhf.deb

build-docker-image:
docker build --rm -q -f Dockerfile -t $(IMAGE_NAME):build .
Expand Down Expand Up @@ -89,12 +87,6 @@ build/linux/$(NAME)-arm64:
-ldflags "-s -w -X main.Version=$(VERSION)" \
-o build/linux/$(NAME)-arm64

build/linux/$(NAME)-armhf:
mkdir -p build/linux
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 go build -a -asmflags=-trimpath=/src -gcflags=-trimpath=/src \
-ldflags "-s -w -X main.Version=$(VERSION)" \
-o build/linux/$(NAME)-armhf

build/deb/$(NAME)_$(VERSION)_amd64.deb: build/linux/$(NAME)-amd64
export SOURCE_DATE_EPOCH=$(shell git log -1 --format=%ct) \
&& mkdir -p build/deb \
Expand Down Expand Up @@ -135,26 +127,6 @@ build/deb/$(NAME)_$(VERSION)_arm64.deb: build/linux/$(NAME)-arm64
build/linux/$(NAME)-arm64=/usr/bin/$(NAME) \
LICENSE=/usr/share/doc/$(NAME)/copyright

build/deb/$(NAME)_$(VERSION)_armhf.deb: build/linux/$(NAME)-armhf
export SOURCE_DATE_EPOCH=$(shell git log -1 --format=%ct) \
&& mkdir -p build/deb \
&& fpm \
--architecture armhf \
--category utils \
--description "$$PACKAGE_DESCRIPTION" \
--input-type dir \
--license 'MIT License' \
--maintainer "$(MAINTAINER_NAME) <$(EMAIL)>" \
--name $(NAME) \
--output-type deb \
--package build/deb/$(NAME)_$(VERSION)_armhf.deb \
--url "https://github.com/$(MAINTAINER)/$(REPOSITORY)" \
--vendor "" \
--version $(VERSION) \
--verbose \
build/linux/$(NAME)-armhf=/usr/bin/$(NAME) \
LICENSE=/usr/share/doc/$(NAME)/copyright

clean:
rm -rf build release validation

Expand All @@ -180,52 +152,39 @@ release: build bin/gh-release bin/gh-release-body
rm -rf release && mkdir release
tar -zcf release/$(NAME)_$(VERSION)_linux_amd64.tgz -C build/linux $(NAME)-amd64
tar -zcf release/$(NAME)_$(VERSION)_linux_arm64.tgz -C build/linux $(NAME)-arm64
tar -zcf release/$(NAME)_$(VERSION)_linux_armhf.tgz -C build/linux $(NAME)-armhf
tar -zcf release/$(NAME)_$(VERSION)_darwin_amd64.tgz -C build/darwin $(NAME)-amd64
tar -zcf release/$(NAME)_$(VERSION)_darwin_arm64.tgz -C build/darwin $(NAME)-arm64
cp build/deb/$(NAME)_$(VERSION)_amd64.deb release/$(NAME)_$(VERSION)_amd64.deb
cp build/deb/$(NAME)_$(VERSION)_arm64.deb release/$(NAME)_$(VERSION)_arm64.deb
cp build/deb/$(NAME)_$(VERSION)_armhf.deb release/$(NAME)_$(VERSION)_armhf.deb
bin/gh-release create $(MAINTAINER)/$(REPOSITORY) $(VERSION) $(shell git rev-parse --abbrev-ref HEAD)
bin/gh-release-body $(MAINTAINER)/$(REPOSITORY) v$(VERSION)

release-packagecloud:
@$(MAKE) release-packagecloud-deb

release-packagecloud-deb: build/deb/$(NAME)_$(VERSION)_amd64.deb build/deb/$(NAME)_$(VERSION)_arm64.deb build/deb/$(NAME)_$(VERSION)_armhf.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/bionic build/deb/$(NAME)_$(VERSION)_amd64.deb
release-packagecloud-deb: build/deb/$(NAME)_$(VERSION)_amd64.deb build/deb/$(NAME)_$(VERSION)_arm64.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/focal build/deb/$(NAME)_$(VERSION)_amd64.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/jammy build/deb/$(NAME)_$(VERSION)_amd64.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/debian/buster build/deb/$(NAME)_$(VERSION)_amd64.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/debian/bullseye build/deb/$(NAME)_$(VERSION)_amd64.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/debian/bookworm build/deb/$(NAME)_$(VERSION)_amd64.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/focal build/deb/$(NAME)_$(VERSION)_arm64.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/jammy build/deb/$(NAME)_$(VERSION)_arm64.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/debian/bullseye build/deb/$(NAME)_$(VERSION)_arm64.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/debian/bookworm build/deb/$(NAME)_$(VERSION)_arm64.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/focal build/deb/$(NAME)_$(VERSION)_armhf.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/jammy build/deb/$(NAME)_$(VERSION)_armhf.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/raspbian/buster build/deb/$(NAME)_$(VERSION)_armhf.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/raspbian/bullseye build/deb/$(NAME)_$(VERSION)_armhf.deb

validate:
mkdir -p validation
lintian build/deb/$(NAME)_$(VERSION)_amd64.deb || true
lintian build/deb/$(NAME)_$(VERSION)_arm64.deb || true
lintian build/deb/$(NAME)_$(VERSION)_armhf.deb || true
dpkg-deb --info build/deb/$(NAME)_$(VERSION)_amd64.deb
dpkg-deb --info build/deb/$(NAME)_$(VERSION)_arm64.deb
dpkg-deb --info build/deb/$(NAME)_$(VERSION)_armhf.deb
dpkg -c build/deb/$(NAME)_$(VERSION)_amd64.deb
dpkg -c build/deb/$(NAME)_$(VERSION)_arm64.deb
dpkg -c build/deb/$(NAME)_$(VERSION)_armhf.deb
cd validation && ar -x ../build/deb/$(NAME)_$(VERSION)_amd64.deb
cd validation && ar -x ../build/deb/$(NAME)_$(VERSION)_arm64.deb
cd validation && ar -x ../build/deb/$(NAME)_$(VERSION)_armhf.deb
ls -lah build/deb validation
sha1sum build/deb/$(NAME)_$(VERSION)_amd64.deb
sha1sum build/deb/$(NAME)_$(VERSION)_arm64.deb
sha1sum build/deb/$(NAME)_$(VERSION)_armhf.deb
cd /home/runner/work/$(REPOSITORY)/$(REPOSITORY) && bats test.bats

prebuild:
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ lambda-builder build --generate-image --builder dotnet

#### Building an image

A docker image can be produced from the generated artifact by specifying the `--generate-image` flag. This also allows for multiple `--label` flags as well as specifying a single image tag via either `-t` or `--tag`:
A docker image can be produced from the generated artifact by specifying the `--generate-image` flag. This also allows for multiple `--label` flags as well as specifying a single image tag via either `-t` or `--tag`:

```shell
# will write a lambda.zip in the specified path
Expand Down Expand Up @@ -111,7 +111,7 @@ aws lambda invoke --endpoint http://localhost:9001 --no-sign-request --function-
curl -d '{}' http://localhost:9001/2015-03-31/functions/function.handler/invocations

# the function can also be invoked directly from a container if desired
docker run --rm "lambda-builder/$APP:latest" function.handler '{"name": "World"}'
docker run --rm "lambda-builder/$APP:latest" function.handler '{"name": "World"}'
```

#### Generating a Procfile
Expand Down Expand Up @@ -141,7 +141,9 @@ Internally, `lambda-builder` detects a given language and builds the app accordi
- dotnet6
- dotnetcore3.1
- `go`
- default build image: `lambci/lambda:build-go1.x`
- default build image:
- With `go.mod`: `golang:1.21-bookworm`
- Without `go.mod`: `golang:1.17-buster`
- requirement: `go.mod` or `main.go`
- runtimes:
- provided.al2
Expand Down
15 changes: 13 additions & 2 deletions builders/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ type GoBuilder struct {

func NewGoBuilder(config Config) (GoBuilder, error) {
var err error
config.BuilderBuildImage, err = getBuildImage(config, "lambci/lambda:build-go1.x")
defaultBuilder := "golang:1.21-bookworm"
if !io.FileExistsInDirectory(config.WorkingDirectory, "go.mod") {
defaultBuilder = "golang:1.17-bullseye"
}

config.BuilderBuildImage, err = getBuildImage(config, defaultBuilder)
if err != nil {
return GoBuilder{}, err
}
Expand Down Expand Up @@ -79,11 +84,12 @@ install-gomod() {
go mod download 2>&1 | indent
else
puts-step "Missing go.mod, downloading dependencies via go get"
go env -w GO111MODULE=off
go get
fi
puts-step "Compiling via go build"
go build -o bootstrap main.go 2>&1 | indent
CGO_ENABLED=0 go build -o bootstrap main.go 2>&1 | indent
}
hook-pre-compile() {
Expand Down Expand Up @@ -111,6 +117,11 @@ hook-package() {
return
fi
if ! command -v zip >/dev/null 2>&1; then
puts-step "Installing zip dependency for packaging"
apt update && apt install -y --no-install-recommends zip
fi
puts-step "Creating package at lambda.zip"
zip -q -r lambda.zip bootstrap
mv lambda.zip /var/task/lambda.zip
Expand Down
17 changes: 8 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ require (
github.com/BurntSushi/toml v1.3.2
github.com/Masterminds/semver v1.5.0
github.com/alexellis/go-execute v0.6.0
github.com/aws/aws-lambda-go v1.41.0
github.com/aws/aws-lambda-go v1.46.0
github.com/codeclysm/extract/v3 v3.1.1
github.com/google/uuid v1.3.0
github.com/josegonzalez/cli-skeleton v0.9.0
github.com/mattn/go-isatty v0.0.19
github.com/google/uuid v1.6.0
github.com/josegonzalez/cli-skeleton v0.15.0
github.com/mattn/go-isatty v0.0.20
github.com/mitchellh/cli v1.1.5
github.com/posener/complete v1.2.3
github.com/rs/zerolog v1.30.0
github.com/rs/zerolog v1.32.0
github.com/spf13/pflag v1.0.5
gopkg.in/yaml.v2 v2.4.0
)
Expand All @@ -25,7 +25,6 @@ require (
github.com/armon/go-radix v1.0.0 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/h2non/filetype v1.1.3 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
Expand All @@ -41,8 +40,8 @@ require (
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/ulikunitz/xz v0.5.11 // indirect
golang.org/x/crypto v0.11.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/term v0.10.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/term v0.16.0 // indirect
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect
)
Loading

0 comments on commit 1270aad

Please sign in to comment.