Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docker file #1278

Merged
merged 2 commits into from
Sep 4, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 3 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,32 +63,13 @@ all-cross: ontology-cross tools-cross abi
format:
$(GOFMT) -w main.go

docker/payload: docker/build/bin/ontology docker/Dockerfile
@echo "Building ontology payload"
@mkdir -p $@
@cp docker/Dockerfile $@
@cp docker/build/bin/ontology $@
@touch $@

docker/build/bin/%: Makefile
@echo "Building ontology in docker"
@mkdir -p docker/build/bin docker/build/pkg
@$(DRUN) --rm \
-v $(abspath docker/build/bin):/go/bin \
-v $(abspath docker/build/pkg):/go/pkg \
-v $(GOPATH)/src:/go/src \
-w /go/src/github.com/ontio/ontology \
golang:1.9.5-stretch \
$(GC) $(BUILD_NODE_PAR) -o docker/build/bin/ontology main.go
@touch $@

docker: Makefile docker/payload docker/Dockerfile
docker: Makefile
@echo "Building ontology docker"
@$(DBUILD) -t $(DOCKER_NS)/ontology docker/payload
@docker tag $(DOCKER_NS)/ontology $(DOCKER_NS)/ontology:$(DOCKER_TAG)
@$(DBUILD) --no-cache -t $(DOCKER_NS)/ontology:$(DOCKER_TAG) - < docker/Dockerfile
@touch $@

clean:
rm -rf *.8 *.o *.out *.6 *exe coverage
rm -rf ontology ontology-* tools docker/payload docker/build
rm -rf ontology ontology-* tools

22 changes: 15 additions & 7 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# 1. Stage one: build ontology
FROM golang:1.13 AS build
WORKDIR /app
RUN git clone https://github.com/ontio/ontology.git && \
cd ontology && \
make

# 2. Stage two: copy compiled binary from prev builded container(referenced by name build)
FROM ubuntu:18.04
WORKDIR /app
COPY --from=build /app/ontology/ontology ontology

FROM tianon/ubuntu-core:14.04
ENV ONTOLOGY_PATH /var/ontology
RUN mkdir -p $ONTOLOGY_PATH
COPY ontology $ONTOLOGY_PATH
EXPOSE 20334 20335 20336 20337 20338 20339
WORKDIR $ONTOLOGY_PATH
ENTRYPOINT ["./ontology"]

EXPOSE 20334 20335 20336 20337 20338 20339
#NOTE! we highly recommand that you put data dir to a mounted volume, e.g. --data-dir /data/Chain
#write data to docker image is *not* a best practice
ENTRYPOINT ["/app/ontology"]