-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dockerize and Added tools for dockerizing
- Loading branch information
1 parent
ed765cc
commit b76224b
Showing
9 changed files
with
265 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
**/.git | ||
*/ | ||
* | ||
!Dockerfile | ||
!konlpy_grpc_gateway/ | ||
!tools/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
FROM golang:latest AS gateway-build | ||
WORKDIR /build | ||
COPY konlpy_grpc_gateway/go.mod konlpy_grpc_gateway/go.sum ./ | ||
RUN go mod download | ||
COPY konlpy_grpc_gateway . | ||
RUN go build -o konlpy_grpc_gateway . | ||
|
||
FROM python:latest AS swagger-merge | ||
WORKDIR /build | ||
COPY --from=gateway-build /build/_generated/ /build/konlpy_grpc_gateway/_generated/ | ||
COPY tools/merge.swagger.py merge.swagger.py | ||
RUN python3 merge.swagger.py | ||
|
||
FROM minhoryang/konlpy:v0.5.2 AS konlpy-grpc | ||
LABEL maintainer="Minho Ryang <[email protected]>" | ||
LABEL org.label-schema.schema-version="1.0" | ||
LABEL org.label-schema.name="minhoryang/konlpy-grpc" | ||
LABEL org.label-schema.description="KoNLPy gRPC/HTTP Server" | ||
LABEL org.label-schema.version="v0.1.0" | ||
|
||
WORKDIR /app | ||
COPY --from=ochinchina/supervisord:latest /usr/local/bin/supervisord /usr/local/bin/supervisord | ||
COPY --from=gateway-build /build/konlpy_grpc_gateway /app/konlpy_grpc_gateway | ||
COPY --from=swagger-merge /build/konlpy_grpc_gateway/_generated/index.swagger.json /app/_generated/index.swagger.json | ||
COPY tools/supervisor.conf /app/supervisor.conf | ||
|
||
# RUN python3 -m pip install konlpy-grpc | ||
RUN python3 -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ konlpy-grpc | ||
|
||
CMD ["/usr/local/bin/supervisord", "-c", "supervisor.conf"] | ||
ENTRYPOINT [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import glob | ||
import json | ||
import pathlib | ||
|
||
ROOT = pathlib.Path.cwd() / "konlpy_grpc_gateway" / "_generated" | ||
RESULT = {} | ||
RESULT["swagger"] = "2.0" | ||
RESULT["info"] = {} | ||
RESULT["info"]["title"] = "KoNLPy Service" | ||
RESULT["info"]["version"] = "0.1.0" | ||
RESULT["consumes"] = ["application/json"] | ||
RESULT["produces"] = ["application/json"] | ||
RESULT["paths"] = {} | ||
RESULT["definitions"] = {} | ||
for swagger_file in ROOT.glob("*.swagger.json"): | ||
operation_id_prefix = swagger_file.name.split(".")[0] | ||
swagger_json = json.loads(swagger_file.read_bytes()) | ||
for path in swagger_json["paths"].values(): | ||
for method in path.values(): | ||
method["operationId"] = f"{operation_id_prefix}{method['operationId']}" | ||
RESULT["paths"].update(swagger_json["paths"]) | ||
RESULT["definitions"].update(swagger_json["definitions"]) | ||
|
||
(ROOT / "index.swagger.json").write_text(json.dumps(RESULT)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[program:grpc] | ||
command = python3 -m konlpy_grpc server | ||
|
||
[program:http] | ||
command = ./konlpy_grpc_gateway -alsologtostderr -endpoint localhost:50051 -swagger_dir _generated | ||
depends_on = grpc |