From c386f12613bc90e87e5e563f2b5bdd091bc6db98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Delattre?= Date: Thu, 2 Feb 2017 14:39:48 +0100 Subject: [PATCH] Add target in the Makefile to build the docker image --- Makefile | 10 +++++++++- docker/Dockerfile-production | 6 ++++++ webpack.config.js | 4 ++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 docker/Dockerfile-production diff --git a/Makefile b/Makefile index 1c1038f..f4b945e 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: docker migration dev clean test +.PHONY: docker migration dev clean test build_docker_image DB_USER=test DB_PASS=test @@ -24,6 +24,14 @@ docker: $(DOCKER_COMPOSE) up -d sleep 8 +build_docker_image: + rm -rf canapeapp + mkdir canapeapp + yarn build + CGO_ENABLED=0 go build -v -o canapeapp/app src/main.go + docker build --tag canapeapp:latest --file docker/Dockerfile-production . + rm -rf canapeapp + migration-schema: docker $(MIGRATION) -path $(MIGRATION_SCHEMA) up diff --git a/docker/Dockerfile-production b/docker/Dockerfile-production new file mode 100644 index 0000000..2ae1a63 --- /dev/null +++ b/docker/Dockerfile-production @@ -0,0 +1,6 @@ +FROM alpine:3.5 + +COPY canapeapp /opt/canapeapp +WORKDIR /opt/canapeapp +RUN chmod +x /opt/canapeapp +CMD ["/opt/canapeapp"] diff --git a/webpack.config.js b/webpack.config.js index 0b62a0f..2671987 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,6 +2,10 @@ var webpack = require("webpack"); var path = require("path"); var BUILD_DIR = path.resolve(__dirname, 'build/public/'); +if (process.env.NODE_ENV === 'production') { + BUILD_DIR = path.resolve(__dirname, 'canapeapp/public/'); +} + var SRC_DIR = path.resolve(__dirname, 'src/public/js'); const config = {