Skip to content

Commit

Permalink
fix(server): fix version parsing (#1586)
Browse files Browse the repository at this point in the history
* fix(server): fix version parsing

* Revert to `SB_VERSION` and set it in the `Node.js` app build step.

* Revert port change.

* Set `SB_VERSION` env variable only where it's needed.
  • Loading branch information
sbruens authored Sep 3, 2024
1 parent a1a819c commit fa3d7c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/shadowbox/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ tasks:
TARGET_DIR: '{{.TARGET_DIR | default (joinPath .OUTPUT_BASE .TARGET_OS .TARGET_ARCH)}}'
NODE_DIR: '{{joinPath .TARGET_DIR "app"}}'
BIN_DIR: '{{joinPath .TARGET_DIR "bin"}}'
VERSION: '{{.VERSION}}'
cmds:
- echo Target platform is {{.TARGET_OS}}/{{.TARGET_ARCH}}
- rm -rf '{{.TARGET_DIR}}'
- mkdir -p '{{.TARGET_DIR}}'
- cp '{{joinPath .TASKFILE_DIR "package.json"}}' '{{.TARGET_DIR}}'
# Build Node.js app
- npx webpack --config='{{joinPath .TASKFILE_DIR "webpack.config.js"}}' --output-path='{{.NODE_DIR}}' ${BUILD_ENV:+--mode="${BUILD_ENV}"}
- SB_VERSION={{.VERSION}} npx webpack --config='{{joinPath .TASKFILE_DIR "webpack.config.js"}}' --output-path='{{.NODE_DIR}}' ${BUILD_ENV:+--mode="${BUILD_ENV}"}
# Copy third_party dependencies
- task: ':third_party:prometheus:copy-{{.TARGET_OS}}-{{.GOARCH}}'
vars: {TARGET_DIR: '{{.BIN_DIR}}'}
Expand Down Expand Up @@ -64,7 +65,7 @@ tasks:
- echo "Using directory {{.RUN_DIR}}"
- mkdir -p '{{.STATE_DIR}}'
- echo '{"hostname":"127.0.0.1"}' > "{{.STATE_CONFIG}}"
- task: make_test_certificate
- task: make_test_certificate
vars: {OUTPUT_DIR: '{{.RUN_DIR}}'}
- node '{{joinPath .OUTPUT_BASE .TARGET_OS .TARGET_ARCH "app/main.js"}}'

Expand All @@ -82,7 +83,7 @@ tasks:
(dict
"x86_64" "node@sha256:a0b787b0d53feacfa6d606fb555e0dbfebab30573277f1fe25148b05b66fa097"
"arm64" "node@sha256:b4b7a1dd149c65ee6025956ac065a843b4409a62068bd2b0cbafbb30ca2fab3b"
) .TARGET_ARCH
) .TARGET_ARCH
}}'
env:
DOCKER_CONTENT_TRUST: '{{.DOCKER_CONTENT_TRUST | default "1"}}'
Expand All @@ -91,7 +92,7 @@ tasks:
cmds:
- rm -rf '{{.IMAGE_ROOT}}'
- mkdir -p '{{.IMAGE_ROOT}}'
- {task: build, vars: {TARGET_OS: linux, TARGET_ARCH: '{{.TARGET_ARCH}}', TARGET_DIR: '{{joinPath .IMAGE_ROOT "/opt/outline-server"}}'}}
- {task: build, vars: {VERSION: '{{.VERSION}}', TARGET_OS: linux, TARGET_ARCH: '{{.TARGET_ARCH}}', TARGET_DIR: '{{joinPath .IMAGE_ROOT "/opt/outline-server"}}'}}
- cp -R '{{joinPath .TASKFILE_DIR "scripts"}}' '{{.IMAGE_ROOT}}/scripts'
- mkdir -p '{{joinPath .IMAGE_ROOT "/etc/periodic/weekly"}}'
- cp '{{joinPath .TASKFILE_DIR "scripts" "update_mmdb.sh"}}' '{{joinPath .IMAGE_ROOT "/etc/periodic/weekly/"}}'
Expand Down Expand Up @@ -128,7 +129,7 @@ tasks:
- rm -rf '{{.RUN_DIR}}'
- mkdir -p '{{.HOST_STATE_DIR}}'
- echo '{"hostname":"127.0.0.1"}' > "{{.STATE_CONFIG}}"
- task: make_test_certificate
- task: make_test_certificate
vars: {OUTPUT_DIR: '{{.HOST_STATE_DIR}}'}
- |
docker_command=(
Expand All @@ -143,7 +144,7 @@ tasks:
{{- end}}
# Where the container keeps its persistent state.
-v "{{.HOST_STATE_DIR}}:{{.CONTAINER_STATE_DIR}}"
-v "{{.HOST_STATE_DIR}}:{{.CONTAINER_STATE_DIR}}"
-e "SB_STATE_DIR={{.CONTAINER_STATE_DIR}}"
# Port number and path prefix used by the server manager API.
Expand Down
4 changes: 2 additions & 2 deletions src/shadowbox/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# limitations under the License.

ARG NODE_IMAGE
ARG VERSION

FROM ${NODE_IMAGE}
ARG VERSION

# Save metadata on the software versions we are using.
LABEL shadowbox.node_version=16.18.0
Expand All @@ -36,4 +36,4 @@ RUN /etc/periodic/weekly/update_mmdb.sh
# Install shadowbox.
WORKDIR /opt/outline-server

CMD /cmd.sh
CMD ["/cmd.sh"]

0 comments on commit fa3d7c5

Please sign in to comment.