diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..185e663 --- /dev/null +++ b/.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* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2fb471e --- /dev/null +++ b/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"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..4372d1e --- /dev/null +++ b/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~~~" /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 + +"$@"