Skip to content

Commit

Permalink
WIP docker prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
PicoCreator committed Jan 10, 2020
1 parent 71f168d commit 5273c3f
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 64 deletions.
35 changes: 0 additions & 35 deletions Dockerfile

This file was deleted.

Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions docker-dev-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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");
docker build -t $(basename "$PWD") .
# docker run -d -P --name $(basename "$PWD") $(basename "$PWD");
37 changes: 37 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
#
Empty file modified docker-notes.md
100644 → 100755
Empty file.
85 changes: 58 additions & 27 deletions dockerfile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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" ]
# Setup the entrypoint
ENTRYPOINT [ "/application/docker-entrypoint.sh" ]
CMD []

0 comments on commit 5273c3f

Please sign in to comment.