Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,4 @@ Use the mu-script `setup-ide` to install these without running in development mo
Changes to dependencies in `package.json` will be picked up and an updated `package-lock.json` will be copied into the mounted sources provided `package-lock.json` is enabled. Local packages are installed through the `package-lock.json` and the template's dependencies are merged in. The `package-lock.json` thus only contains your own dependencies and should not conflict with future upgrades in the template.

### Custom build commands
To execute custom bash statements during the image build (e.g. to install aditional system libraries), provide an `on-build.sh` script in the root of your service. It will be automatically picked up and executed by the Docker build.
To execute custom bash statements during the image build (e.g. to install aditional system libraries), provide an `on-build.sh` script in the root of your service. It will be automatically picked up and executed by the Docker build. Make sure to return a non-zero return code in case of failure, in order to fail the build. For example using `set -eo` to exit on any non-zero statuses or if any part of a pipe fails.
3 changes: 3 additions & 0 deletions build-production.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
# so we can warn at runtime in case developers accidentally mount
# sources without setting the development environment variable.

# Fail build on error
set -eo

source ./helpers.sh

# Copy sources from /app to where they can be built
Expand Down
4 changes: 4 additions & 0 deletions npm-install-dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/bash

# Fail build on error
set -eo

source ./helpers.sh

environment=$1
Expand Down
4 changes: 4 additions & 0 deletions transpile-sources.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/bash

# Fail build on error
set -eo

source ./helpers.sh

####
Expand Down
9 changes: 6 additions & 3 deletions validate-package-json.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
#!/bin/bash

# Fail build on error
set -eo

cd /usr/src/app/
node ./validate-package-json.js
cd /usr/src/app/app/

## Ensure package.json has module
if [ -f /usr/src/app/app/package.json ]
then
cat /usr/src/app/app/package.json | jq -e ".type" > /dev/null
if [ $? -ne 0 ]
PACKAGE_TYPE=`cat /usr/src/app/app/package.json | jq -r ".type"`
if [[ "$PACKAGE_TYPE" -eq "null" ]]
then
echo '[WARNING] Adding "type": "module" to your package.json.'
echo 'To remove this warning, add "type": "module" at the same level as "name" in your package.json'
sed -i '0,/{/s/{/{\n "type": "module",/' /usr/src/app/app/package.json
else
PACKAGE_TYPE=`cat /usr/src/app/app/package.json | jq -r ".type"`
if [[ "$PACKAGE_TYPE" -ne "module" ]]
then
echo '[WARNING] DIFFERENT TYPE THAN "module" IN package.json; CONTINUING WITH UNSPECIFIED BEHAVIOUR'
Expand Down