Skip to content
Permalink
Browse files

build docker image and push it on every release

  • Loading branch information...
mlapshin committed Oct 8, 2018
1 parent ed4fe4e commit df0d43dcd9b61504a020268372658c1416c750a6
Showing with 30 additions and 71 deletions.
  1. +2 −0 .dockerignore
  2. +2 −0 .travis.yml
  3. +7 −10 {demo → }/Dockerfile
  4. +5 −0 Makefile
  5. +0 −41 demo/deployment.yml
  6. +0 −20 demo/service.yml
  7. +14 −0 web.go
@@ -0,0 +1,2 @@
.gopath
.git
@@ -25,6 +25,8 @@ script:
- GOOS=windows GOARCH=amd64 BINSUFFIX=-windows-amd64.exe make
- GOOS=windows GOARCH=386 BINSUFFIX=-windows-386.exe make
- GOOS=darwin GOARCH=amd64 BINSUFFIX=-darwin-amd64 make
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- "[ ! -z \"$TRAVIS_TAG\" ] && make docker"

before_install:
- curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
@@ -1,12 +1,9 @@
FROM clkao/postgres-plv8:9.6-2.0
FROM postgres:10.5

RUN apt-get update -q && apt-get install -y -q wget
COPY demo/bundle.ndjson.gzip .
COPY bin/fhirbase-linux-amd64 /usr/bin/fhirbase

RUN wget https://github.com/fhirbase/fhirbase/releases/download/nightly-build/fhirbase-linux-amd64 && \
mv fhirbase-linux-amd64 fhirbase && \
chmod +x fhirbase

COPY bundle.ndjson.gzip .
RUN chmod +x /usr/bin/fhirbase

RUN mkdir /pgdata && chown postgres:postgres /pgdata

@@ -17,13 +14,13 @@ RUN PGDATA=/pgdata /docker-entrypoint.sh postgres & until psql -U postgres -c '\
sleep 5; \
done && \
psql -U postgres -c 'create database fhirbase;' && \
./fhirbase -d fhirbase init && \
./fhirbase -d fhirbase load --mode=insert ./bundle.ndjson.gzip
fhirbase -d fhirbase init && \
fhirbase -d fhirbase load --mode=insert ./bundle.ndjson.gzip

EXPOSE 3000

CMD pg_ctl -D /pgdata start && until psql -U postgres -c '\q'; do \
>&2 echo "Postgres is starting up..."; \
sleep 5; \
done && \
/fhirbase -d fhirbase web
exec fhirbase -d fhirbase web
@@ -63,3 +63,8 @@ clean:
.PHONY: tests
test: fmt lint vendor packr
cd $(BASE) && go test $(ARGS)

.PHONY: docker
docker: Dockerfile bin/fhirbase-linux-amd64
docker build . -t fhirbase/fhirbase:$(VERSION)
docker push fhirbase/fhirbase:nightly-ed4fe4e

This file was deleted.

This file was deleted.

14 web.go
@@ -1,10 +1,12 @@
package main

import (
"context"
"fmt"
"log"
"net/http"
"os"
"os/signal"
"time"

"github.com/gobuffalo/packr"
@@ -164,6 +166,18 @@ func WebCommand(c *cli.Context) error {
IdleTimeout: 15 * time.Second,
}

idleConnsClosed := make(chan struct{})
go func() {
sigint := make(chan os.Signal, 1)
signal.Notify(sigint, os.Interrupt)
<-sigint

if err := server.Shutdown(context.Background()); err != nil {
logger.Printf("HTTP server Shutdown: %v\n", err)
}
close(idleConnsClosed)
}()

logger.Printf("Starting web server on %s\n", addr)

if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed {

0 comments on commit df0d43d

Please sign in to comment.
You can’t perform that action at this time.