generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: bundle sqlc binaries in ftl release binary
also implements the Go API for invoking generate
- Loading branch information
Showing
16 changed files
with
497 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM alpine:latest | ||
|
||
RUN apk add --no-cache bash curl tar | ||
|
||
WORKDIR /app | ||
|
||
COPY scripts/download-sqlc /app/download-sqlc | ||
|
||
RUN chmod +x /app/download-sqlc | ||
|
||
ENV SQLC_VERSION="" | ||
|
||
CMD ["/app/download-sqlc"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package sqlc | ||
|
||
import ( | ||
"embed" | ||
"fmt" | ||
"io" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
//go:embed resources/* | ||
var embeddedResources embed.FS | ||
|
||
func extractEmbeddedFile(resourceName, destPath string) error { | ||
if err := os.MkdirAll(filepath.Dir(destPath), 0750); err != nil { | ||
return fmt.Errorf("failed to create destination directory: %w", err) | ||
} | ||
|
||
srcFile, err := embeddedResources.Open(filepath.Join("resources", resourceName)) | ||
if err != nil { | ||
return fmt.Errorf("failed to open embedded resource %s: %w", resourceName, err) | ||
} | ||
defer srcFile.Close() | ||
|
||
destFile, err := os.OpenFile(destPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) | ||
if err != nil { | ||
return fmt.Errorf("failed to create destination file: %w", err) | ||
} | ||
defer destFile.Close() | ||
|
||
if _, err := io.Copy(destFile, srcFile); err != nil { | ||
return fmt.Errorf("failed to copy file contents: %w", err) | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.