Skip to content

Commit 9d80da6

Browse files
Define a container that executes migration then exits.
resolves issue #1
1 parent 4a4597f commit 9d80da6

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Largely based on https://github.com/reactioncommerce/docker-base/blob/trunk/images/node-dev/12.14.1-v3/Dockerfile
2+
FROM node:12.14.1-alpine
3+
4+
# hadolint ignore=DL3018
5+
RUN apk --no-cache --update add bash curl less shadow su-exec tini vim python2 make git
6+
SHELL ["/bin/bash", "-o", "pipefail", "-o", "errexit", "-u", "-c"]
7+
8+
# Allow yarn/npm to create ./node_modules
9+
RUN mkdir -p /usr/local/src/app && chown node:node /usr/local/src/app
10+
11+
# Install latest NPM
12+
RUN npm install -g npm@latest
13+
14+
COPY . /usr/local/src/app
15+
16+
WORKDIR /usr/local/src/app
17+
18+
RUN npm install
19+
20+
USER root
21+
22+
ENTRYPOINT ["tini", "--", "/usr/local/src/app/scripts/entrypoint.sh"]

scripts/entrypoint.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
# Please Use Google Shell Style: https://google.github.io/styleguide/shell.xml
4+
5+
# ---- Start unofficial bash strict mode boilerplate
6+
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
7+
set -o errexit # always exit on error
8+
set -o errtrace # trap errors in functions as well
9+
set -o pipefail # don't ignore exit codes when piping output
10+
set -o posix # more strict failures in subshells
11+
# set -x # enable debugging
12+
13+
IFS=$'\n\t'
14+
# ---- End unofficial bash strict mode boilerplate
15+
16+
# change the app user's uid:gid to match the repo root directory's
17+
# uid=$(stat -c "%u" .)
18+
# if [[ "${uid}" == "0" ]]; then
19+
# # Never run as root even if directory is owned by root.
20+
# # Fall back to 1000 which we know is the app user
21+
# uid=1000
22+
# fi
23+
# usermod --uid "${uid}" --non-unique "${run_user}" |& grep -v "no changes" || true
24+
25+
# scripts_dir="$(dirname "${BASH_SOURCE[0]}")"
26+
27+
# "${scripts_dir}/fix-volumes.sh" "${run_user}"
28+
29+
# run_user="node"
30+
command=(npx migrator migrate -y)
31+
32+
unset IFS
33+
# exec su-exec "${run_user}" "${command[@]}"
34+
exec "${command[@]}"
35+
exit

0 commit comments

Comments
 (0)