1
0
Fork 0

Add Docker image

pull/2/head
Ambrose Chua 2018-09-26 23:04:26 +08:00
parent 64dac49326
commit f365ef0a1b
3 changed files with 93 additions and 0 deletions

21
.dockerignore Normal file
View File

@ -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 Normal file
View File

@ -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 Normal file
View File

@ -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
"$@"