Skip to content

Commit

Permalink
fix: enable empirica serve in docker container (#504)
Browse files Browse the repository at this point in the history
  • Loading branch information
npaton committed Feb 5, 2024
1 parent 434e36a commit 0994940
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/fix-docker-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@empirica/core": patch
---

Enable `empirica serve` to run in the official Docker container image.
11 changes: 6 additions & 5 deletions .github/workflows/build_and_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ on:
paths-ignore:
- "cmds/proxy/**"
- ".github/workflows/on_push_proxy.yaml"
pull_request:
paths-ignore:
- "cmds/proxy/**"
- ".github/workflows/on_push_proxy.yaml"
# pull_request:
# paths-ignore:
# - "cmds/proxy/**"
# - ".github/workflows/on_push_proxy.yaml"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -25,7 +25,8 @@ jobs:
npm:
name: Build npm package
runs-on: ubuntu-latest
if: github.repository == 'empiricaly/empirica' && github.event.pull_request.draft == false
if: github.repository == 'empiricaly/empirica'
# && github.event.pull_request.draft == false
steps:
- name: Checkout Repo
uses: actions/checkout@v3
Expand Down
6 changes: 5 additions & 1 deletion internal/build/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,18 @@ func FindCurrentBinaryVersion() (*Build, error) {
return build, nil
}

// errNoInstalledVersions is returned when no versions are installed, which
// would imply we are running empirica without the proxy.
var ErrNoInstalledVersions = errors.New("no installed versions")

func GetLatestInstalledVersion() (*Build, error) {
versions, err := GetInstalledVersions()
if err != nil {
return nil, errors.Wrap(err, "get installed versions")
}

if len(versions) == 0 {
return nil, errors.New("no installed versions")
return nil, ErrNoInstalledVersions
}

return versions[len(versions)-1], nil
Expand Down
19 changes: 9 additions & 10 deletions internal/bundle/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,15 @@ func Serve(ctx context.Context, config *empirica.Config, in string, clean, devMo
log.Fatal().Err(err).Msg("invalid config")
}

b, err := build.FindCurrentBinaryVersion()
if err != nil {
log.Fatal().Err(err).Msg("failed to find bundle version")
}

// If we are not running the correct version, restart with the correct
// version. The new version will automatically be picked up on restart since
// the version in the bundle will have already been exported to the
// .empirica/release file in the current dir.
if b.Version != build.Current().Version && os.Getenv(build.BuildSelectionEnvVar) == "" {
if b, err := build.FindCurrentBinaryVersion(); err != nil {
if !errors.Is(err, build.ErrNoInstalledVersions) {
log.Fatal().Err(err).Msg("failed to find bundle version")
}
} else if b.Version != build.Current().Version && os.Getenv(build.BuildSelectionEnvVar) == "" {
// If we are not running the correct version, restart with the correct
// version. The new version will automatically be picked up on restart since
// the version in the bundle will have already been exported to the
// .empirica/release file in the current dir.
log.Info().
Str("from", build.Current().Version).
Str("to", b.Version).
Expand Down

0 comments on commit 0994940

Please sign in to comment.