Skip to content

Commit 2fdf505

Browse files
committed
Merge pull request #62 from dlsniper/smaller-container
Smaller container (fixes #56)
2 parents 32129fe + 6443831 commit 2fdf505

File tree

6 files changed

+114
-3
lines changed

6 files changed

+114
-3
lines changed

.dockerignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@ LICENSE
55

66
screenshot.png
77
Godeps/
8-
9-
10-

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ _testmain.go
3535
*.exe
3636
*.test
3737
*.prof
38+
39+
output.log

container-make.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
3+
set -x
4+
5+
CONTAINER_NAME=${1}
6+
CONTAINER_TAG=${2}
7+
8+
PROJECT_NAME='github.com/tobegit3hub/seagull'
9+
PROJECT_DIR="${PWD}"
10+
VENDOR_DIR='Godeps/_workspace'
11+
12+
CONTAINER_GOPATH='/go'
13+
CONTAINER_PROJECT_DIR="${CONTAINER_GOPATH}/src/${PROJECT_NAME}"
14+
CONTAINER_PROJECT_GOPATH="${CONTAINER_PROJECT_DIR}/${VENDOR_DIR}:${CONTAINER_GOPATH}"
15+
16+
docker run --rm \
17+
-v ${PROJECT_DIR}:${CONTAINER_PROJECT_DIR} \
18+
-e GOPATH=${CONTAINER_PROJECT_GOPATH} \
19+
-e CGO_ENABLED=0 \
20+
-e GODEBUG=netdns=go \
21+
-w "${CONTAINER_PROJECT_DIR}" \
22+
golang:1.5.3-alpine \
23+
go build -v -o seagull seagull.go
24+
25+
# Disable this to strip the debug information from the binary and shave off about 4Mb making the binary from 12mb to 8mb
26+
# It means this can't be debugged by delve, gdb et al. but the side is even better
27+
strip "${PROJECT_DIR}/seagull"
28+
29+
docker build -f ${PROJECT_DIR}/seagull.docker \
30+
-t ${CONTAINER_NAME}:${CONTAINER_TAG} \
31+
--build-arg BINARY_FILE=./seagull \
32+
"${PROJECT_DIR}"

container-release.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
set -x
4+
5+
CONTAINER_NAME=${1}
6+
CONTAINER_TAG=${2}
7+
8+
PROJECT_DIR="${PWD}"
9+
10+
${PROJECT_DIR}/container-make.sh "${CONTAINER_NAME}" "${CONTAINER_TAG}"
11+
12+
# TODO docker tag command should go here
13+
14+
# TODO docker push command should go here

container-test.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
3+
set -x
4+
5+
PROJECT_NAME='github.com/tobegit3hub/seagull'
6+
PROJECT_DIR="${PWD}"
7+
VENDOR_DIR='Godeps/_workspace'
8+
9+
CONTAINER_GOPATH='/go'
10+
CONTAINER_PROJECT_DIR="${CONTAINER_GOPATH}/src/${PROJECT_NAME}"
11+
CONTAINER_PROJECT_GOPATH="${CONTAINER_PROJECT_DIR}/${VENDOR_DIR}:${CONTAINER_GOPATH}"
12+
13+
docker run --rm \
14+
--net="host" \
15+
-v ${PROJECT_DIR}:${CONTAINER_PROJECT_DIR} \
16+
-e CI=true \
17+
-e GODEBUG=netdns=go \
18+
-e GOPATH=${CONTAINER_PROJECT_GOPATH} \
19+
-w "${CONTAINER_PROJECT_DIR}" \
20+
golang:1.5.3 \
21+
go test -v -race ./... 2> output.log
22+
23+
EXIT_CODE=$?
24+
25+
cat output.log
26+
27+
if [ ${EXIT_CODE} != 0 ]; then
28+
rm -f output.log
29+
exit ${EXIT_CODE}
30+
fi
31+
32+
# Check for race conditions as we don't have a proper exit code for them from the tool
33+
cat output.log | grep -v 'WARNING: DATA RACE'
34+
35+
EXIT_CODE=$?
36+
37+
rm -f output.log
38+
39+
# If we don't find a match then we don't have a race condition
40+
if [ ${EXIT_CODE} == 1 ]; then
41+
exit 0
42+
fi
43+
44+
exit ${EXIT_CODE}

seagull.docker

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM alpine:3.3
2+
MAINTAINER tobe "[email protected]"
3+
MAINTAINER Florin Patan "[email protected]"
4+
5+
ARG BINARY_FILE
6+
7+
# DNS stuff
8+
RUN echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf
9+
10+
# SSL certs
11+
RUN apk add --update ca-certificates \
12+
&& rm -rf /var/cache/apk/*
13+
14+
# Binary
15+
ADD conf/app.conf /seagull/conf/app.conf
16+
COPY views /seagull/views
17+
COPY static /seagull/static
18+
ADD $BINARY_FILE /seagull/seagull
19+
20+
# Runtime
21+
EXPOSE 10086
22+
CMD ["/seagull/seagull"]

0 commit comments

Comments
 (0)