diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4a06d962..c018009c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ permissions: jobs: goreleaser: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 @@ -19,7 +19,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.22 + go-version-file: "go.mod" - name: Run GoReleaser uses: goreleaser/goreleaser-action@v6.0.0 with: diff --git a/go.mod b/go.mod index 1440efae..28a04f32 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module github.com/zeabur/zbpack -go 1.21.0 +go 1.22.0 -toolchain go1.21.6 +toolchain go1.22.7 require ( github.com/spf13/afero v1.11.0 @@ -10,10 +10,10 @@ require ( ) require ( - github.com/containerd/typeurl/v2 v2.2.0 // indirect + github.com/containerd/typeurl/v2 v2.2.2 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/fatih/color v1.17.0 // indirect - github.com/fsnotify/fsnotify v1.7.0 // indirect + github.com/fatih/color v1.18.0 // indirect + github.com/fsnotify/fsnotify v1.8.0 // indirect github.com/gkampitakis/ciinfo v0.3.0 // indirect github.com/gkampitakis/go-diff v1.3.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect @@ -22,9 +22,8 @@ require ( github.com/hashicorp/hcl v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect - github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5 // indirect - github.com/juju/loggo v1.0.0 // indirect - github.com/klauspost/compress v1.17.9 // indirect + github.com/juju/errors v1.0.0 // indirect + github.com/klauspost/compress v1.17.11 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/magiconair/properties v1.8.7 // indirect @@ -33,11 +32,12 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect - github.com/pelletier/go-toml/v2 v2.2.2 // indirect + github.com/pelletier/go-toml/v2 v2.2.3 // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect - github.com/sagikazarmark/locafero v0.4.0 // indirect + github.com/sagikazarmark/locafero v0.6.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/pflag v1.0.5 // indirect @@ -46,15 +46,12 @@ require ( github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect github.com/tidwall/sjson v1.2.5 // indirect - github.com/ulikunitz/xz v0.5.11 // indirect + github.com/ulikunitz/xz v0.5.12 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect - google.golang.org/protobuf v1.33.0 // indirect - gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect + golang.org/x/sys v0.26.0 // indirect + google.golang.org/protobuf v1.35.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect - gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) @@ -66,11 +63,11 @@ require ( github.com/distribution/reference v0.6.0 github.com/evanw/esbuild v0.24.0 github.com/gkampitakis/go-snaps v0.5.7 - github.com/goccy/go-yaml v1.12.0 + github.com/goccy/go-yaml v1.13.5 github.com/google/go-github/v63 v63.0.0 github.com/google/uuid v1.6.0 github.com/iancoleman/strcase v0.3.0 - github.com/moby/buildkit v0.16.0 + github.com/moby/buildkit v0.17.0 github.com/moznion/go-optional v0.12.0 github.com/otiai10/copy v1.14.0 github.com/pan93412/envexpander/v3 v3.0.0 @@ -79,6 +76,6 @@ require ( github.com/spf13/cast v1.7.0 github.com/spf13/cobra v1.8.1 github.com/spf13/viper v1.19.0 - golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 + golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c golang.org/x/text v0.19.0 ) diff --git a/go.sum b/go.sum index 6dacc0e5..8d9ba82b 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ github.com/aws/aws-sdk-go v1.55.5 h1:KKUZBfBoyqy5d3swXyiC7Q76ic40rYcbqH7qjh59kzU github.com/aws/aws-sdk-go v1.55.5/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU= github.com/codeclysm/extract/v3 v3.1.1 h1:iHZtdEAwSTqPrd+1n4jfhr1qBhUWtHlMTjT90+fJVXg= github.com/codeclysm/extract/v3 v3.1.1/go.mod h1:ZJi80UG2JtfHqJI+lgJSCACttZi++dHxfWuPaMhlOfQ= -github.com/containerd/typeurl/v2 v2.2.0 h1:6NBDbQzr7I5LHgp34xAXYF5DOTQDn05X58lsPEmzLso= -github.com/containerd/typeurl/v2 v2.2.0/go.mod h1:8XOOxnyatxSWuG8OfsZXVnAF4iZfedjS/8UHSPJnX4g= +github.com/containerd/typeurl/v2 v2.2.2 h1:3jN/k2ysKuPCsln5Qv8bzR9cxal8XjkxPogJfSNO31k= +github.com/containerd/typeurl/v2 v2.2.2/go.mod h1:95ljDnPfD3bAbDJRugOiShd/DlAAsxGtUBhJxIn7SCk= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -18,26 +18,28 @@ github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5Qvfr github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/evanw/esbuild v0.24.0 h1:GZ78naTLp7FKr+K7eNuM/SLs5maeiHYRPsTg6kmdsSE= github.com/evanw/esbuild v0.24.0/go.mod h1:D2vIQZqV/vIf/VRHtViaUtViZmG7o+kKmlBfVQuRi48= -github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= -github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= +github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= -github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= -github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= +github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M= +github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= +github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= +github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= github.com/gkampitakis/ciinfo v0.3.0 h1:gWZlOC2+RYYttL0hBqcoQhM7h1qNkVqvRCV1fOvpAv8= github.com/gkampitakis/ciinfo v0.3.0/go.mod h1:1NIwaOcFChN4fa/B0hEBdAb6npDlFL8Bwx4dfRLRqAo= github.com/gkampitakis/go-diff v1.3.2 h1:Qyn0J9XJSDTgnsgHRdz9Zp24RaJeKMUHg2+PDZZdC4M= github.com/gkampitakis/go-diff v1.3.2/go.mod h1:LLgOrpqleQe26cte8s36HTWcTmMEur6OPYerdAAS9tk= github.com/gkampitakis/go-snaps v0.5.7 h1:uVGjHR4t4pPHU944udMx7VKHpwepZXmvDMF+yDmI0rg= github.com/gkampitakis/go-snaps v0.5.7/go.mod h1:ZABkO14uCuVxBHAXAfKG+bqNz+aa1bGPAg8jkI0Nk8Y= -github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= -github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= -github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= -github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= -github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE= -github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= -github.com/goccy/go-yaml v1.12.0 h1:/1WHjnMsI1dlIBQutrvSMGZRQufVO3asrHfTwfACoPM= -github.com/goccy/go-yaml v1.12.0/go.mod h1:wKnAMd44+9JAAnGQpWVEgBzGt3YuTaQ4uXoHvE4m7WU= +github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= +github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= +github.com/go-playground/validator/v10 v10.22.1 h1:40JcKH+bBNGFczGuoBYgX4I6m/i27HYW8P9FDk5PbgA= +github.com/go-playground/validator/v10 v10.22.1/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= +github.com/goccy/go-yaml v1.13.5 h1:/Hh9Q3d1Q2T7E8ECUUS7Uh53FBGKLfetvQoSV7kLViU= +github.com/goccy/go-yaml v1.13.5/go.mod h1:IjYwxUiJDoqpx2RmbdjMUceGHZwYLon3sfOGl5Hi9lc= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -61,35 +63,24 @@ github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9Y github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= -github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a/go.mod h1:UJSiEoRfvx3hP73CvoARgeLjaIOjybY9vj8PUPPFGeU= -github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5 h1:rhqTjzJlm7EbkELJDKMTU7udov+Se0xZkWmugr6zGok= -github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= -github.com/juju/loggo v1.0.0 h1:Y6ZMQOGR9Aj3BGkiWx7HBbIx6zNwNkxhVNOHU2i1bl0= -github.com/juju/loggo v1.0.0/go.mod h1:NIXFioti1SmKAlKNuUwbMenNdef59IF52+ZzuOmHYkg= -github.com/juju/testing v0.0.0-20200510222523-6c8c298c77a0 h1:+WWUkhnTjV6RNOxkcwk79qrjeyHEHvBzlneueBsatX4= -github.com/juju/testing v0.0.0-20200510222523-6c8c298c77a0/go.mod h1:hpGvhGHPVbNBraRLZEhoQwFLMrjK8PSlO4D3nDjKYXo= +github.com/juju/errors v1.0.0 h1:yiq7kjCLll1BiaRuNY53MGI0+EQ3rF6GB+wvboZDefM= +github.com/juju/errors v1.0.0/go.mod h1:B5x9thDqx0wIMH3+aLIMP9HjItInYWObRovoCFM5Qe8= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= -github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= +github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= -github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= -github.com/lunixbochs/vtclean v0.0.0-20160125035106-4fbf7632a2c6/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= +github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= +github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/maruel/natural v1.1.1 h1:Hja7XhhmvEFhcByqDoHz9QZbkWey+COd9xWfCfn1ioo= github.com/maruel/natural v1.1.1/go.mod h1:v+Rfd79xlw1AgVBjbO0BEQmptqb5HvL/k9GRHB7ZKEg= -github.com/mattn/go-colorable v0.0.6/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.0-20160806122752-66b8e73f3f5c/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= @@ -97,8 +88,8 @@ github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/moby/buildkit v0.16.0 h1:wOVBj1o5YNVad/txPQNXUXdelm7Hs/i0PUFjzbK0VKE= -github.com/moby/buildkit v0.16.0/go.mod h1:Xqx/5GlrqE1yIRORk0NSCVDFpQAU1WjlT6KHYZdisIQ= +github.com/moby/buildkit v0.17.0 h1:ZA/4AxwBbve1f3ZaNNJQiCBtTV62R6YweWNwq4A+sTc= +github.com/moby/buildkit v0.17.0/go.mod h1:ru8NFyDHD8HbuKaLXJIjK9nr3x6FZR+IWjtF07S+wdM= github.com/moznion/go-optional v0.12.0 h1:gM9YSR7kusSQHiaq2IDHU7WoJNGETT1NbuB15XU4ebA= github.com/moznion/go-optional v0.12.0/go.mod h1:UP85Bc+uliSDFDzN7Zw8D6gBO1bdPChKFpNu1DJfCqE= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= @@ -109,11 +100,13 @@ github.com/otiai10/mint v1.5.1 h1:XaPLeE+9vGbuyEHem1JNk3bYc7KKqyI/na0/mLd/Kks= github.com/otiai10/mint v1.5.1/go.mod h1:MJm72SBthJjz8qhefc4z1PYEieWmy8Bku7CjcAqyUSM= github.com/pan93412/envexpander/v3 v3.0.0 h1:B4xopnYqr7newpEfq86kP8QA/R4UutJT55b+E90t6d4= github.com/pan93412/envexpander/v3 v3.0.0/go.mod h1:QS/joCUILI5BVO45O/7bnrquv+KBr7e0fgBknfaTSgQ= -github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= -github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= +github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M= +github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo= +github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -121,8 +114,8 @@ github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/f github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= -github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= +github.com/sagikazarmark/locafero v0.6.0 h1:ON7AQg37yzcRPU69mt7gwhFEBwxI6P9T4Qu3N51bwOk= +github.com/sagikazarmark/locafero v0.6.0/go.mod h1:77OmuIc6VTraTXKXIs/uvUxKGUXjE1GbemJYHqdNjX0= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/samber/lo v1.47.0 h1:z7RynLwP5nbyRscyvcD043DWYoOcYRv3mV8lBeqOCLc= @@ -142,12 +135,6 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= @@ -162,8 +149,8 @@ github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY= github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28= -github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= -github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= +github.com/ulikunitz/xz v0.5.12 h1:37Nm15o69RwBkXM0J6A5OlE67RZTfzUxTj8fB3dfcsc= +github.com/ulikunitz/xz v0.5.12/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= @@ -171,16 +158,18 @@ go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN8 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= -golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= -golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 h1:hNQpMuAJe5CtcUqCXaWga3FHu+kQvCqcsoVaQgSV60o= -golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= +golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= +golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= +golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY= +golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -192,8 +181,8 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= @@ -206,21 +195,15 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU= -golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= +google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20160105164936-4f90aeace3a2/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 h1:VpOs+IwYnYBaFnrNAeB8UUWtL3vEUnzSCL1nVjPhqrw= -gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/dart/dart.go b/internal/dart/dart.go index 963e2275..b51f24ca 100644 --- a/internal/dart/dart.go +++ b/internal/dart/dart.go @@ -11,7 +11,7 @@ func GenerateDockerfile(meta types.PlanMeta) (string, error) { build := meta["build"] if meta["framework"] == "flutter" { - return `FROM ubuntu:latest + dockerfile := `FROM ubuntu:latest RUN apt-get update && apt-get install -y curl git unzip xz-utils zip libglu1-mesa RUN git clone https://github.com/flutter/flutter.git /usr/local/flutter ENV PATH="/usr/local/flutter/bin:/usr/local/flutter/bin/cache/dart-sdk/bin:${PATH}" @@ -24,7 +24,19 @@ RUN flutter pub get FROM scratch COPY --from=0 /app/build/web / -`, nil +` + + // We run it with caddy for Containerized mode. + if serverless, ok := meta["serverless"]; ok && serverless != "true" { + caddy := ` +FROM zeabur/caddy-static AS runtime +COPY --from=1 / /usr/share/caddy +` + + dockerfile += caddy + } + + return dockerfile, nil } if meta["framework"] == "serverpod" { diff --git a/internal/dart/dart_test.go b/internal/dart/dart_test.go new file mode 100644 index 00000000..3f412028 --- /dev/null +++ b/internal/dart/dart_test.go @@ -0,0 +1,38 @@ +package dart_test + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/zeabur/zbpack/internal/dart" +) + +func TestGenerateDockerfileStatic(t *testing.T) { + t.Parallel() + + t.Run("flutter, serverless", func(t *testing.T) { + t.Parallel() + + dockerfile, err := dart.GenerateDockerfile(map[string]string{ + "framework": "flutter", + "serverless": "true", + }) + + assert.NoError(t, err) + assert.Contains(t, dockerfile, "FROM scratch") + assert.NotContains(t, dockerfile, "FROM zeabur/caddy-static") + }) + + t.Run("flutter, non-serverless", func(t *testing.T) { + t.Parallel() + + dockerfile, err := dart.GenerateDockerfile(map[string]string{ + "framework": "flutter", + "serverless": "false", + }) + + assert.NoError(t, err) + assert.Contains(t, dockerfile, "FROM scratch") + assert.Contains(t, dockerfile, "FROM zeabur/caddy-static") + }) +} diff --git a/internal/dart/identify.go b/internal/dart/identify.go index f7604933..d5c2a38f 100644 --- a/internal/dart/identify.go +++ b/internal/dart/identify.go @@ -113,7 +113,7 @@ func (i *identify) PlanMeta(options plan.NewPlannerOptions) types.PlanMeta { if od := determineOutputDir(ctx); od != "" { meta["serverless"] = strconv.FormatBool( - utils.GetExplicitServerlessConfig(ctx.Config).TakeOr(false), + utils.GetExplicitServerlessConfig(ctx.Config).TakeOr(true), ) meta["outputDir"] = od } diff --git a/internal/gleam/gleam.go b/internal/gleam/gleam.go index 033e8e1c..457b6282 100644 --- a/internal/gleam/gleam.go +++ b/internal/gleam/gleam.go @@ -8,8 +8,7 @@ import ( // GenerateDockerfile generates the Dockerfile for Gleam projects. func GenerateDockerfile(m types.PlanMeta) (string, error) { - if m["serverless"] == "true" { - return `FROM ghcr.io/gleam-lang/gleam:v1.3.2-erlang-alpine + dockerfile := `FROM ghcr.io/gleam-lang/gleam:v1.3.2-erlang-alpine RUN apk add --no-cache elixir RUN mix local.hex --force RUN mix local.rebar --force @@ -17,25 +16,22 @@ COPY . /build/ RUN cd /build \ && gleam export erlang-shipment \ && mv build/erlang-shipment /app \ - && rm -r /build + && rm -r /build` + if m["serverless"] == "true" { + dockerfile += ` FROM scratch AS output COPY --from=0 /app / -`, nil - } - - return `FROM ghcr.io/gleam-lang/gleam:v1.3.2-erlang-alpine -RUN apk add --no-cache elixir -RUN mix local.hex --force -RUN mix local.rebar --force -COPY . /build/ -RUN cd /build \ - && gleam export erlang-shipment \ - && mv build/erlang-shipment /app \ - && rm -r /build +` + } else { + dockerfile += ` WORKDIR /app ENTRYPOINT ["/app/entrypoint.sh"] -CMD ["run"]`, nil +CMD ["run"] +` + } + + return dockerfile, nil } type pack struct { diff --git a/internal/gleam/gleam_test.go b/internal/gleam/gleam_test.go new file mode 100644 index 00000000..74f1a08d --- /dev/null +++ b/internal/gleam/gleam_test.go @@ -0,0 +1,34 @@ +package gleam_test + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/zeabur/zbpack/internal/gleam" +) + +func TestGenerateDockerfile(t *testing.T) { + t.Parallel() + + t.Run("serverless", func(t *testing.T) { + t.Parallel() + + dockerfile, err := gleam.GenerateDockerfile(map[string]string{ + "serverless": "true", + }) + + assert.NoError(t, err) + assert.Contains(t, dockerfile, "\nFROM scratch AS output") + }) + + t.Run("non-serverless", func(t *testing.T) { + t.Parallel() + + dockerfile, err := gleam.GenerateDockerfile(map[string]string{ + "serverless": "false", + }) + + assert.NoError(t, err) + assert.Contains(t, dockerfile, "\nWORKDIR /app") + }) +} diff --git a/internal/nodejs/__snapshots__/template_test.snap b/internal/nodejs/__snapshots__/template_test.snap index c1de93c7..1f8026ce 100755 --- a/internal/nodejs/__snapshots__/template_test.snap +++ b/internal/nodejs/__snapshots__/template_test.snap @@ -73,6 +73,10 @@ RUN yarn build FROM scratch AS output COPY --from=build /src///app/dist / +FROM zeabur/caddy-static AS runtime +COPY --from=output / /usr/share/caddy + + --- @@ -176,6 +180,10 @@ RUN yarn install FROM scratch AS output COPY --from=build /src/myservice//app/dist / +FROM zeabur/caddy-static AS runtime +COPY --from=output / /usr/share/caddy + + --- diff --git a/internal/nodejs/plan.go b/internal/nodejs/plan.go index b9845915..fa6e0990 100644 --- a/internal/nodejs/plan.go +++ b/internal/nodejs/plan.go @@ -6,6 +6,7 @@ import ( "fmt" "log" "path/filepath" + "slices" "strconv" "strings" @@ -376,7 +377,13 @@ func GetBuildScript(ctx *nodePlanContext) string { return bs.Unwrap() } + scriptsOrderedKey := make([]string, 0, len(packageJSON.Scripts)) for key := range packageJSON.Scripts { + scriptsOrderedKey = append(scriptsOrderedKey, key) + } + slices.Sort(scriptsOrderedKey) + + for _, key := range scriptsOrderedKey { if strings.Contains(key, "build") { *bs = optional.Some(key) return bs.Unwrap() @@ -730,6 +737,12 @@ func GetStartCmd(ctx *nodePlanContext) string { return cmd.Unwrap() } + // if the app is deployed as static files, we should not start the app. + if GetStaticOutputDir(ctx) != "" { + *cmd = optional.Some("") + return cmd.Unwrap() + } + if startCmd, err := plan.Cast(ctx.Config.Get(plan.ConfigStartCommand), cast.ToStringE).Take(); err == nil { *cmd = optional.Some(startCmd) return cmd.Unwrap() @@ -998,8 +1011,12 @@ func GetMeta(opt GetMetaOptions) types.PlanMeta { meta["serverless"] = strconv.FormatBool(serverless) } - // only set outputDir if there is no custom start command (because if there is, it shouldn't be a static project) - if buildCmd == "" { + startCmd := GetStartCmd(ctx) + meta["startCmd"] = startCmd + + // only set outputDir if there is no start command + // (because if there is, it shouldn't be a static project) + if startCmd == "" { staticOutputDir := GetStaticOutputDir(ctx) if staticOutputDir != "" { meta["outputDir"] = staticOutputDir @@ -1007,8 +1024,5 @@ func GetMeta(opt GetMetaOptions) types.PlanMeta { } } - startCmd := GetStartCmd(ctx) - meta["startCmd"] = startCmd - return meta } diff --git a/internal/nodejs/template_test.go b/internal/nodejs/template_test.go index a6f4d8c8..f78d33b0 100644 --- a/internal/nodejs/template_test.go +++ b/internal/nodejs/template_test.go @@ -6,6 +6,7 @@ import ( "github.com/gkampitakis/go-snaps/snaps" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/zeabur/zbpack/internal/nodejs" ) @@ -242,3 +243,37 @@ func TestTemplate_Bun(t *testing.T) { assert.NoError(t, err) snaps.MatchSnapshot(t, result) } + +func TestTemplate_ServerlessOutputDir(t *testing.T) { + t.Parallel() + + t.Run("with serverless", func(t *testing.T) { + ctx := nodejs.TemplateContext{ + NodeVersion: "18", + InstallCmd: "RUN yarn install", + Serverless: true, + OutputDir: "/app/dist", + } + + result, err := ctx.Execute() + assert.NoError(t, err) + + require.Contains(t, result, "FROM scratch AS output") + require.NotContains(t, result, "FROM zeabur/caddy-static AS runtime") + }) + + t.Run("without serverless", func(t *testing.T) { + ctx := nodejs.TemplateContext{ + NodeVersion: "18", + InstallCmd: "RUN yarn install", + Serverless: false, + OutputDir: "/app/dist", + } + + result, err := ctx.Execute() + assert.NoError(t, err) + + require.Contains(t, result, "FROM scratch AS output") + require.Contains(t, result, "FROM zeabur/caddy-static AS runtime") + }) +} diff --git a/internal/nodejs/templates/template.Dockerfile b/internal/nodejs/templates/template.Dockerfile index af8ad355..5dcde1cb 100644 --- a/internal/nodejs/templates/template.Dockerfile +++ b/internal/nodejs/templates/template.Dockerfile @@ -41,6 +41,10 @@ COPY --from=build /src/{{ .AppDir }} / {{ else if ne .OutputDir "" }} FROM scratch AS output COPY --from=build /src/{{ .AppDir }}/{{ .OutputDir }} / +{{ if not .Serverless }} +FROM zeabur/caddy-static AS runtime +COPY --from=output / /usr/share/caddy +{{ end }} {{ else }} EXPOSE 8080 CMD {{ .StartCmd }}{{ end }} diff --git a/internal/static/identify.go b/internal/static/identify.go index b2df88f9..8ad569fc 100644 --- a/internal/static/identify.go +++ b/internal/static/identify.go @@ -33,10 +33,6 @@ func (i *identify) PlanMeta(options plan.NewPlannerOptions) types.PlanMeta { planMeta := types.PlanMeta{"serverless": strconv.FormatBool(serverless)} - if !serverless { - planMeta["expose"] = "80" - } - if utils.HasFile(options.Source, "hugo.toml", "config/_default/hugo.toml") { planMeta["framework"] = "hugo" return planMeta diff --git a/internal/static/static.go b/internal/static/static.go index e0c0a5b7..7c5d2e58 100644 --- a/internal/static/static.go +++ b/internal/static/static.go @@ -49,7 +49,7 @@ COPY . / // We run it with caddy for Containerized mode. if serverless, ok := meta["serverless"]; ok && serverless != "true" { - caddy := `FROM caddy AS runtime + caddy := `FROM zeabur/caddy-static AS runtime COPY --from=output / /usr/share/caddy ` diff --git a/pkg/transformer/static.go b/pkg/transformer/static.go index 2b9b9792..dd21baa5 100644 --- a/pkg/transformer/static.go +++ b/pkg/transformer/static.go @@ -16,10 +16,7 @@ import ( // TransformStatic copies the static files from output to .zeabur/output/static // and creates a config.json file for SPA func TransformStatic(ctx *Context) error { - hasOutputDir := ctx.PlanMeta["outputDir"] != "" - isServerlessStatic := ctx.PlanType == types.PlanTypeStatic && ctx.PlanMeta["serverless"] == "true" - - if !hasOutputDir && !isServerlessStatic { + if ctx.PlanMeta["outputDir"] == "" || ctx.PlanMeta["serverless"] != "true" { return ErrSkip } diff --git a/pkg/transformer/static_test.go b/pkg/transformer/static_test.go index e0aede08..a99686ea 100644 --- a/pkg/transformer/static_test.go +++ b/pkg/transformer/static_test.go @@ -39,7 +39,8 @@ func TestTransformStatic(t *testing.T) { BuildkitPath: buildkitPath, AppPath: appPath, PlanMeta: map[string]string{ - "outputDir": "dist", + "outputDir": "dist", + "serverless": "true", }, PlanType: types.PlanTypeStatic, } @@ -86,7 +87,8 @@ func TestTransformStatic(t *testing.T) { BuildkitPath: buildkitPath, AppPath: appPath, PlanMeta: map[string]string{ - "outputDir": "dist", + "outputDir": "dist", + "serverless": "true", }, PlanType: types.PlanTypeStatic, } diff --git a/pkg/zeaburpack/image.go b/pkg/zeaburpack/image.go index 9436eb80..ca611f4f 100644 --- a/pkg/zeaburpack/image.go +++ b/pkg/zeaburpack/image.go @@ -75,7 +75,7 @@ func buildImage(opt *buildImageOptions) error { "--local", "dockerfile=" + path.Dir(dockerfilePath), } - if opt.PlanMeta["serverless"] == "true" || opt.PlanMeta["outputDir"] != "" || opt.PlanType == types.PlanTypeNix { + if (opt.PlanMeta["serverless"] == "true" && opt.PlanMeta["outputDir"] != "") || opt.PlanType == types.PlanTypeNix { buildKitCmd = append(buildKitCmd, "--output", "type=tar,dest="+ServerlessTarPath) } else { t := "image" diff --git a/pkg/zeaburpack/main.go b/pkg/zeaburpack/main.go index 66dd8b8f..a779f67a 100644 --- a/pkg/zeaburpack/main.go +++ b/pkg/zeaburpack/main.go @@ -223,7 +223,7 @@ func Build(opt *BuildOptions) error { opt.Log("\033[90m" + "The compiled serverless function has been saved in the .zeabur directory." + "\033[0m\n") } else { opt.Log("\033[90m" + "To run the image, use the following command:" + "\033[0m\n") - if m["outputDir"] != "" || (t == types.PlanTypeStatic && m["serverless"] == "true") { + if m["outputDir"] != "" && m["serverless"] == "true" { opt.Log("npx serve .zeabur/output/static\n") } else { opt.Log("docker run -p 8080:8080 -e PORT=8080 -it %s\n", *opt.ResultImage) diff --git a/tests/real_project_test.go b/tests/real_project_test.go index 168c589c..292215bc 100644 --- a/tests/real_project_test.go +++ b/tests/real_project_test.go @@ -264,6 +264,11 @@ var projects = []struct { owner: "zeabur", repo: "qwik-city-template", }, + { + name: "nodejs-vite-vanilla", + owner: "zeabur", + repo: "vite-vanilla-template", + }, { name: "nodejs-a-lot-of-dependencies", dir: "nodejs-a-lot-of-dependencies", diff --git a/tests/snapshots/dart-flutter.txt b/tests/snapshots/dart-flutter.txt index 88562c44..f2034772 100644 --- a/tests/snapshots/dart-flutter.txt +++ b/tests/snapshots/dart-flutter.txt @@ -4,4 +4,4 @@ Meta: build: "RUN flutter build web" framework: "flutter" outputDir: "build/web" - serverless: "false" + serverless: "true" diff --git a/tests/snapshots/nodejs-angular.txt b/tests/snapshots/nodejs-angular.txt index 00033d03..6da695da 100644 --- a/tests/snapshots/nodejs-angular.txt +++ b/tests/snapshots/nodejs-angular.txt @@ -7,6 +7,7 @@ Meta: framework: "angular" installCmd: "COPY package.json* tsconfig.json* .npmrc* .\nCOPY package-lock.json* .\nRUN npm install" nodeVersion: "20" + outputDir: "dist/angular-template/browser" packageManager: "npm" serverless: "true" startCmd: "" diff --git a/tests/snapshots/nodejs-docusaurus.txt b/tests/snapshots/nodejs-docusaurus.txt index f077d7d3..a08730f4 100644 --- a/tests/snapshots/nodejs-docusaurus.txt +++ b/tests/snapshots/nodejs-docusaurus.txt @@ -7,6 +7,7 @@ Meta: framework: "docusaurus" installCmd: "COPY package.json* tsconfig.json* .npmrc* .\nCOPY pnpm-lock.yaml* .\nRUN pnpm install" nodeVersion: "16" + outputDir: "build" packageManager: "pnpm" serverless: "true" startCmd: "" diff --git a/tests/snapshots/nodejs-rspress.txt b/tests/snapshots/nodejs-rspress.txt index 97de4cd6..a31fb7d8 100644 --- a/tests/snapshots/nodejs-rspress.txt +++ b/tests/snapshots/nodejs-rspress.txt @@ -7,6 +7,7 @@ Meta: framework: "rspress" installCmd: "COPY package.json* tsconfig.json* .npmrc* .\nCOPY pnpm-lock.yaml* .\nRUN pnpm install" nodeVersion: "20" + outputDir: "doc_build" packageManager: "pnpm" serverless: "true" startCmd: "" diff --git a/tests/snapshots/nodejs-slidev.txt b/tests/snapshots/nodejs-slidev.txt index ce85499c..e6749313 100644 --- a/tests/snapshots/nodejs-slidev.txt +++ b/tests/snapshots/nodejs-slidev.txt @@ -7,6 +7,7 @@ Meta: framework: "sli.dev" installCmd: "COPY package.json* tsconfig.json* .npmrc* .\nCOPY pnpm-lock.yaml* .\nRUN pnpm install" nodeVersion: "20" + outputDir: "dist" packageManager: "pnpm" serverless: "true" startCmd: "" diff --git a/tests/snapshots/nodejs-starlight.txt b/tests/snapshots/nodejs-starlight.txt index 03ffe58b..76f5fa82 100644 --- a/tests/snapshots/nodejs-starlight.txt +++ b/tests/snapshots/nodejs-starlight.txt @@ -7,6 +7,7 @@ Meta: framework: "astro-starlight" installCmd: "COPY package.json* tsconfig.json* .npmrc* .\nCOPY pnpm-lock.yaml* .\nRUN pnpm install" nodeVersion: "20" + outputDir: "dist" packageManager: "pnpm" serverless: "true" startCmd: "" diff --git a/tests/snapshots/nodejs-umi.txt b/tests/snapshots/nodejs-umi.txt index 7ccc4152..05338f8d 100644 --- a/tests/snapshots/nodejs-umi.txt +++ b/tests/snapshots/nodejs-umi.txt @@ -7,6 +7,7 @@ Meta: framework: "umi" installCmd: "COPY package.json* tsconfig.json* .npmrc* .\nCOPY pnpm-lock.yaml* .\nRUN pnpm install" nodeVersion: "20" + outputDir: "dist" packageManager: "pnpm" serverless: "true" startCmd: "" diff --git a/tests/snapshots/nodejs-vite-vanilla.txt b/tests/snapshots/nodejs-vite-vanilla.txt new file mode 100644 index 00000000..77af4716 --- /dev/null +++ b/tests/snapshots/nodejs-vite-vanilla.txt @@ -0,0 +1,13 @@ +PlanType: nodejs + +Meta: + appDir: "" + buildCmd: "yarn build" + bun: "false" + framework: "vite" + installCmd: "COPY package.json* tsconfig.json* .npmrc* .\nRUN yarn install" + nodeVersion: "20" + outputDir: "dist" + packageManager: "unknown" + serverless: "true" + startCmd: "" diff --git a/tests/snapshots/nodejs-vitepress.txt b/tests/snapshots/nodejs-vitepress.txt index 80d44aa3..e53f1594 100644 --- a/tests/snapshots/nodejs-vitepress.txt +++ b/tests/snapshots/nodejs-vitepress.txt @@ -7,6 +7,7 @@ Meta: framework: "vitepress" installCmd: "COPY package.json* tsconfig.json* .npmrc* .\nCOPY pnpm-lock.yaml* .\nRUN pnpm install" nodeVersion: "20" + outputDir: "docs/.vitepress/dist" packageManager: "pnpm" serverless: "true" startCmd: "" diff --git a/tests/snapshots/nodejs-vocs.txt b/tests/snapshots/nodejs-vocs.txt index d243cef1..d773d112 100644 --- a/tests/snapshots/nodejs-vocs.txt +++ b/tests/snapshots/nodejs-vocs.txt @@ -7,6 +7,7 @@ Meta: framework: "vocs" installCmd: "COPY package.json* tsconfig.json* .npmrc* .\nCOPY pnpm-lock.yaml* .\nRUN pnpm install" nodeVersion: "20" + outputDir: "docs/dist" packageManager: "pnpm" serverless: "true" startCmd: "" diff --git a/tests/snapshots/static-hexo.txt b/tests/snapshots/static-hexo.txt index eb078a69..d938f010 100644 --- a/tests/snapshots/static-hexo.txt +++ b/tests/snapshots/static-hexo.txt @@ -7,6 +7,7 @@ Meta: framework: "hexo" installCmd: "COPY package.json* tsconfig.json* .npmrc* .\nCOPY yarn.lock* .\nRUN yarn install" nodeVersion: "20" + outputDir: "public" packageManager: "yarn" serverless: "true" startCmd: ""