Skip to content

Commit

Permalink
Add deployment Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihails Strasuns authored and nemanja-boric-sociomantic committed Sep 26, 2018
1 parent 0a14421 commit a311982
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 2 deletions.
2 changes: 0 additions & 2 deletions .dockerignore

This file was deleted.

6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ jobs:
- <<: *test-matrix
env: DMD=2.078.* F=devel COV=1

# Test deployment docker image generation
- stage: Test
script:
- docker build --build-arg DMD=2.078.* --build-arg DIST=xenial
-t dlsnode -f docker/Dockerfile.dlsnode .

# Package matrix
- <<: *package-matrix
env: DMD=1.082.* F=production COV=0
Expand Down
22 changes: 22 additions & 0 deletions docker/Dockerfile.dlsnode
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Duplicate definition of DIST before FROM is needed to be able to use it
# in docker image name:
ARG DIST=xenial
FROM sociomantictsunami/develdlang:$DIST-v7 as builder
# Copies the whole project as makd needs git history:
COPY . /project/
WORKDIR /project/
# Redefine arguments as env vars to be used inside build.sh script:
ARG DIST=xenial
ARG DMD=1.081.*
ENV DMD=$DMD DIST=$DIST
RUN docker/build.sh

ARG DIST=xenial
FROM sociomantictsunami/runtimebase:$DIST-v7
COPY --from=builder /project/build/production/pkg/ /packages/
COPY docker/install.sh .
RUN ./install.sh && rm ./install.sh
COPY doc/etc/config.ini /srv/dlsnode/etc/config.ini
COPY docker/entrypoint.sh /srv/dlsnode/
WORKDIR /srv/dlsnode
CMD ./entrypoint.sh
38 changes: 38 additions & 0 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/sh
set -eu

# Compiler configuration

. submodules/beaver/lib/dlang.sh

set_dc_dver

# Install dependencies

case "$DMD" in
dmd* ) PKG= ;;
1.* ) PKG="dmd1=$DMD-$DIST" ;;
2.*.s* ) PKG="dmd-transitional=$DMD-$DIST" ;;
2.* ) if [ $(echo $DMD | cut -d. -f2) -ge 077 ]; then
PKG="dmd-compiler=$DMD dmd-tools=$DMD libphobos2-dev=$DMD"
else
PKG="dmd-bin=$DMD libphobos2-dev=$DMD"
fi ;;
* ) echo "Unknown \$DMD ($DMD)" >&2; exit 1 ;;
esac

apt update
apt install -y --allow-downgrades \
$PKG \
liblzo2-dev \
libebtree6-dev \
libpcre3-dev \
libgcrypt-dev \
libglib2.0-dev \
libgpg-error-dev

# Build app

if_d 2 make d2conv

make all pkg F=production
11 changes: 11 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
set -e

if [ -z "$CREDENTIALS" ]; then
echo "Must defined CREDENTIALS env var in form of client_name:key"
exit 1
fi;

echo $CREDENTIALS > etc/credentials

dlsnode
11 changes: 11 additions & 0 deletions docker/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
set -xeu

apt update

# Prepare folder structure and install dhtnode

mkdir -p /srv/dlsnode/etc
mkdir -p /srv/dlsnode/log
mkdir -p /srv/dlsnode/data
apt install -y /packages/dlsnode_*

0 comments on commit a311982

Please sign in to comment.