Skip to content

Commit

Permalink
rename default wasp docker so we can use custom dockerignore (#62)
Browse files Browse the repository at this point in the history
* rename default wasp docker so we can use custom dockerignore in product repos

* review comments
  • Loading branch information
skudasov committed Feb 20, 2024
1 parent e651fb6 commit cdf59e9
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Dockerfile → DockerfileWasp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Example Dockerfile for k8s run
# Example DockerfileWasp for k8s run
# Builds all the tests in some directory that must have go.mod
# All tests are built as separate binaries with name "module.test"
FROM golang:1.21 as build
Expand Down
31 changes: 31 additions & 0 deletions DockerfileWasp.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.git-together
.DS_Store
.envrc
*.log
node_modules/
**/node_modules/
vendor/
tmp/

contracts/node_modules
examples/

integration/
integration-scripts/

tools/gethnet/datadir/geth
tools/clroot/db.bolt
tools/clroot/*.log
tools/clroot/tempkeys

core/sgx/target/

core/*.Dockerfile
chainlink

# codeship
codeship-*.yml
*.aes
dockercfg
credentials.env
gcr_creds.env
22 changes: 19 additions & 3 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import (
const (
defaultHelmDeployTimeoutSec = "10m"
defaultArchiveName = "wasp-0.1.8.tgz"
defaultDockerfilePath = "Dockerfile"
defaultDockerfilePath = "DockerfileWasp"
defaultDockerfileIgnorePath = "DockerfileWasp.dockerignore"
defaultBuildScriptPath = "./build.sh"
)

Expand All @@ -33,9 +34,12 @@ const (
//go:embed charts/wasp/wasp-0.1.8.tgz
var defaultChart []byte

//go:embed Dockerfile
//go:embed DockerfileWasp
var DefaultDockerfile []byte

//go:embed DockerfileWasp.dockerignore
var DefaultDockerIgnorefile []byte

//go:embed build_test_image.sh
var DefaultBuildScript []byte

Expand All @@ -52,6 +56,7 @@ type ClusterConfig struct {
UpdateImage bool
DockerCmdExecPath string
DockerfilePath string
DockerIgnoreFilePath string
BuildScriptPath string
BuildCtxPath string
ImageTag string
Expand Down Expand Up @@ -95,7 +100,7 @@ func (m *ClusterConfig) Defaults() error {
m.tmpHelmFilePath, m.ChartPath = defaultArchiveName, defaultArchiveName
}
if m.DockerfilePath == "" {
log.Info().Msg("Using default embedded Dockerfile")
log.Info().Msg("Using default embedded DockerfileWasp")
if err := os.WriteFile(defaultDockerfilePath, DefaultDockerfile, os.ModePerm); err != nil {
return err
}
Expand All @@ -105,6 +110,17 @@ func (m *ClusterConfig) Defaults() error {
}
m.DockerfilePath = p
}
if m.DockerIgnoreFilePath == "" {
log.Info().Msg("Using default embedded DockerfileWasp.dockerignore")
if err := os.WriteFile(defaultDockerfileIgnorePath, DefaultDockerIgnorefile, os.ModePerm); err != nil {
return err
}
p, err := filepath.Abs(defaultDockerfileIgnorePath)
if err != nil {
return err
}
m.DockerIgnoreFilePath = p
}
if m.BuildScriptPath == "" {
log.Info().Msg("Using default build script")
fname := strings.Replace(defaultBuildScriptPath, "./", "", -1)
Expand Down
5 changes: 3 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ tests

### Build

Default [Dockerfile](../Dockerfile) and [build_script](../build_test_image.sh) are working with AWS ECR private repos and building only for `amd64` platform
Default [Dockerfile](../DockerfileWasp) and [build_script](../build_test_image.sh) are working with AWS ECR private repos and building only for `amd64` platform

These vars are required to rebuild default layout and update an image
```
Expand All @@ -57,9 +57,10 @@ By default, we are going one dir up from the cluster entrypoint script and build
```
`BuildCtxPath` is relative to `DockerCmdExecPath`

If for some reason you don't like this layout or can't build like `go test -c ./...`, or you would like to customize your builds then you need to customize default [Dockerfile](../Dockerfile) and [build_script](../build_test_image.sh) and reference them in [cluster_entrypoint](zcluster/cluster_test.go)
If for some reason you don't like this layout or can't build like `go test -c ./...`, or you would like to customize your builds then you need to customize default [Dockerfile](../DockerfileWasp) and [build_script](../build_test_image.sh) and reference them in [cluster_entrypoint](zcluster/cluster_test.go)
```
DockerfilePath: "",
DockerIgnoreFilePath: "",
BuildScriptPath: "",
```

Expand Down
3 changes: 2 additions & 1 deletion examples/zcluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (

func TestClusterEntrypoint(t *testing.T) {
p, err := wasp.NewClusterProfile(&wasp.ClusterConfig{
Namespace: "wasp",
Namespace: "wasp",
// Builds and publishes test image if set to true
UpdateImage: true,
DockerCmdExecPath: "..",
BuildCtxPath: ".",
Expand Down

0 comments on commit cdf59e9

Please sign in to comment.