diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 4a93ce4..0000000 --- a/Dockerfile +++ /dev/null @@ -1,35 +0,0 @@ -# -# Build the golang imageproxy application -# -FROM golang:1.12.6-alpine3.10 AS builder - -# Lets get some useful stiff for building -RUN apk add --no-cache bash git openssh - -# Get the image proxy repo -RUN go get willnorris.com/go/imageproxy/cmd/imageproxy - -# Double checking that the single binary is installed -RUN ls -alh /go/bin - -# -# Lets build the actual container -# -FROM alpine:latest - -# Lets add SSL support -RUN apk --no-cache add ca-certificates - -# Copy over built file into bin -WORKDIR /bin/ -COPY --from=builder /go/bin/imageproxy . - -# Set workdir to /tmp/ -WORKDIR /tmp/ - -# Debug checker -RUN imageproxy --help || true - -# Default entry starts the server at port 80 -ENTRYPOINT [ "imageproxy" ] -CMD [ "-addr", "localhost:80" ] \ No newline at end of file diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/docker-dev-build.sh b/docker-dev-build.sh index 79b8379..fd2a155 100755 --- a/docker-dev-build.sh +++ b/docker-dev-build.sh @@ -2,5 +2,5 @@ docker stop $(docker ps -a | grep $(basename "$PWD") | awk '{print $1}'); docker rm $(docker ps -a | grep $(basename "$PWD") | awk '{print $1}'); -docker build -t $(basename "$PWD") . && -docker run -d -P --name $(basename "$PWD") $(basename "$PWD"); \ No newline at end of file +docker build -t $(basename "$PWD") . +# docker run -d -P --name $(basename "$PWD") $(basename "$PWD"); \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 0000000..7e26281 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +# +# Getting the various configuration settings from command line / environment variable +# +if [ -z "$MAILGUN_EMAIL_DOMAIN" ]; then + echo "[FATAL ERROR] Missing MAILGUN_EMAIL_DOMAIN (eg: inboxkitten.com)"; + exit 1; +else + echo ">> Detected MAILGUN_EMAIL_DOMAIN env variable : $MAILGUN_EMAIL_DOMAIN"; +fi + +if [ -z "$MAILGUN_API_KEY" ]; then + echo ">> Please type in your MAILGUN_API_KEY"; + read -sp '>> MAILGUN_API_KEY : ' MAILGUN_API_KEY; + echo ""; +else + echo ">> Detected MAILGUN_API_KEY env variable : [intentionally redacted]"; +fi + +if [ -z "$WEBSITE_DOMAIN" ]; then + echo ">> Missing WEBSITE_DOMAIN, using MAILGUN_EMAIL_DOMAIN : $MAILGUN_EMAIL_DOMAIN" + export WEBSITE_DOMAIN="$MAILGUN_EMAIL_DOMAIN" +else + echo ">> Detected WEBSITE_DOMAIN env variable : $WEBSITE_DOMAIN"; +fi + +# +# Applying the configuration +# +echo ">> Applying config settings" +cat "$projectDir/api/config/mailgunConfig.sample.js" | envsubst > "$projectDir/api/config/mailgunConfig.js" +cat "$projectDir/ui/config/apiconfig.sample.js" | envsubst > "$projectDir/ui/config/apiconfig.js" + +# +# Doing the required builds +# \ No newline at end of file diff --git a/docker-notes.md b/docker-notes.md old mode 100644 new mode 100755 diff --git a/dockerfile b/dockerfile old mode 100644 new mode 100755 index 0ceee34..9641597 --- a/dockerfile +++ b/dockerfile @@ -1,38 +1,69 @@ -FROM node:12-alpine AS ui-build +# +# +# Base alpine image with all the various dependencies +# +# +FROM node:12-alpine AS baseimage +# Install dependencies +RUN apk add --no-cache gettext -# # -# # Build the golang imageproxy application -# # -# FROM golang:1.12.6-alpine3.10 AS builder +# Setup the /application/ directory +RUN mkdir -p /application/ +# WORKDIR /application/ -# # Lets get some useful stiff for building -# RUN apk add --no-cache bash git openssh +# +# +# Initial docker builder (resets node_modules) +# +# +FROM baseimage AS builder -# # Get the image proxy repo -# RUN go get willnorris.com/go/imageproxy/cmd/imageproxy +# node-gyp installation +RUN apk add --no-cache make gcc g++ python -# # Double checking that the single binary is installed -# RUN ls -alh /go/bin +# Copy over the requried files +COPY api /application/api/ +COPY ui /application/ui/ +COPY docker-entrypoint.sh /application/docker-entrypoint.sh -# # -# # Lets build the actual container -# # -# FROM alpine:latest +# Scrub out node_modules +RUN rm -f /application/api/node_modules +RUN rm -f /application/ui/node_modules + +# Lets do the initial npm install +RUN cd /application/ui && ls && npm install --production +RUN cd /application/api && ls && npm install --production -# # Lets add SSL support -# RUN apk --no-cache add ca-certificates +# +# +# Docker application +# +# +FROM node:12-alpine as application -# # Copy over built file into bin -# WORKDIR /bin/ -# COPY --from=builder /go/bin/imageproxy . +# Copy over the built files +COPY --from=builder /application /application/ -# # Set workdir to /tmp/ -# WORKDIR /tmp/ +# Debugging logging +RUN ls /application -# # Debug checker -# RUN imageproxy --help || true +# Expose the server port +EXPOSE 8000 + +# +# Configurable environment variable +# +ENV MAILGUN_EMAIL_DOMAIN="" +ENV MAILGUN_API_KEY="" +ENV WEBSITE_DOMAIN="" + +# # +# # Preload the NPM installs +# # +# RUN cd /application/ui && ls && npm install +# RUN cd /application/api && ls && npm install -# # Default entry starts the server at port 80 -# ENTRYPOINT [ "imageproxy" ] -# CMD [ "-addr", "localhost:80" ] \ No newline at end of file +# Setup the entrypoint +ENTRYPOINT [ "/application/docker-entrypoint.sh" ] +CMD []