Browse Source

Add Docker image

pull/2/head
Ambrose Chua 3 years ago
parent
commit
f365ef0a1b
  1. 21
      .dockerignore
  2. 36
      Dockerfile
  3. 36
      entrypoint.sh

21
.dockerignore

@ -0,0 +1,21 @@
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw*

36
Dockerfile

@ -0,0 +1,36 @@
FROM node:10-alpine as build
# args
ARG version="0.1.0"
ARG repo="github.com/productionwentdown/dri"
# dependencies
RUN apk add --no-cache git
# source
WORKDIR /app
COPY . .
# build
RUN yarn install
RUN yarn build
FROM alpine:3.8
ARG version
# labels
LABEL org.label-schema.vcs-url="https://github.com/productionwentdown/email-collector"
LABEL org.label-schema.version=${version}
LABEL org.label-schema.schema-version="1.0"
# copy build output
COPY --from=build /app/dist /srv
# copy caddy
COPY --from=productionwentdown/caddy:0.11.0 /bin/caddy /usr/local/bin/caddy
# copy entrypoint.sh
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
CMD ["caddy", "-conf", "/etc/Caddyfile"]

36
entrypoint.sh

@ -0,0 +1,36 @@
#!/bin/sh
BASE_URL=${BASE_URL:=/}
REGISTRY_HOST=${REGISTRY_HOST:=""}
REGISTRY_API=${REGISTRY_API:=""}
REPOSITORIES_PER_PAGE=${REPOSITORIES_PER_PAGE:=0}
TAGS_PER_PAGE=${TAGS_PER_PAGE:=30}
[[ "$USE_PORTUS_EXPLORE" != "true" ]] && [[ "$USE_PORTUS_EXPLORE" != "false" ]] && USE_PORTUS_EXPLORE=false
sed -i "s~<base href=/>~<base href=\"$BASE_URL\">~" /srv/index.html
cat > /etc/Caddyfile << EOF
:80$BASE_URL {
root /srv
browse
rewrite {
regexp (.*)
to {1} {1}/ /
}
}
EOF
cat > /srv/config.json << EOF
{
"registryHost": "$REGISTRY_HOST",
"registryAPI": "$REGISTRY_API",
"repositoriesPerPage": $REPOSITORIES_PER_PAGE,
"tagsPerPage": $TAGS_PER_PAGE,
"usePortusExplore": $USE_PORTUS_EXPLORE
}
EOF
"$@"
Loading…
Cancel
Save