Skip to content

Commit

Permalink
update docker example
Browse files Browse the repository at this point in the history
  • Loading branch information
Daulet Zhanguzin committed Nov 9, 2023
1 parent 5e367fe commit c2f743b
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ release-darwin-%:
release-linux-%:
docker buildx build --platform linux/$* -f release/Dockerfile . -t tokenizers.linux-$*
mkdir -p artifacts/linux-$*
docker run -v $(PWD)/artifacts/linux-$*:/mnt --entrypoint cp tokenizers.linux-$* /go/pkg/mod/github.com/daulet/tokenizers@v0.5.1/libtokenizers.a /mnt/libtokenizers.a
docker run -v $(PWD)/artifacts/linux-$*:/mnt --entrypoint cp tokenizers.linux-$* /go/pkg/mod/github.com/daulet/tokenizers@v0.6.0/libtokenizers.a /mnt/libtokenizers.a
cd artifacts/linux-$* && \
tar -czf libtokenizers.linux-$*.tar.gz libtokenizers.a
mkdir -p artifacts/all
Expand Down
7 changes: 4 additions & 3 deletions example/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

FROM golang:1.21 as builder-go
ARG TARGETPLATFORM
ARG VERSION=v0.6.0
WORKDIR /workspace
RUN curl -fsSL https://github.com/daulet/tokenizers/releases/latest/download/libtokenizers.$(echo ${TARGETPLATFORM} | tr / -).tar.gz | tar xvz
RUN curl -fsSL https://github.com/daulet/tokenizers/releases/download/${VERSION}/libtokenizers.$(echo ${TARGETPLATFORM} | tr / -).tar.gz | tar xvz
COPY ./example .
COPY ./test/data ./test/data
RUN go mod download
COPY ./libtokenizers.a /go/pkg/mod/github.com/daulet/tokenizers@v0.5.1/libtokenizers.a
RUN mv ./libtokenizers.a /go/pkg/mod/github.com/daulet/tokenizers@${VERSION}/libtokenizers.a
# mounting Go cache won't work since we mutate it above
RUN CGO_ENABLED=1 CGO_LDFLAGS="-Wl,--copy-dt-needed-entries" go run main.go
RUN go run main.go
2 changes: 1 addition & 1 deletion example/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/daulet/tokenizers/example

go 1.21

require github.com/daulet/tokenizers v0.5.1
require github.com/daulet/tokenizers v0.6.0
8 changes: 6 additions & 2 deletions example/go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
github.com/daulet/tokenizers v0.5.1 h1:b8E1aUzssSq6Olm5YGJ+ZejtTJ0VHo2w98c1CNJsk6c=
github.com/daulet/tokenizers v0.5.1/go.mod h1:tGnMdZthXdcWY6DGD07IygpwJqiPvG85FQUnhs/wSCs=
github.com/daulet/tokenizers v0.6.0 h1:y6cSPx5YMrXy9dkt7NGWY1l64iwOpD0YU4j6P1Gwqo8=
github.com/daulet/tokenizers v0.6.0/go.mod h1:tGnMdZthXdcWY6DGD07IygpwJqiPvG85FQUnhs/wSCs=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
8 changes: 3 additions & 5 deletions release/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ WORKDIR /workspace
COPY ./src ./src
COPY ./Cargo.toml ./Cargo.toml
COPY ./Cargo.lock ./Cargo.lock
RUN --mount=type=cache,target=/usr/local/cargo/registry,id=${TARGETPLATFORM} \
--mount=type=cache,target=/root/target,id=${TARGETPLATFORM} \
cargo build --release
RUN cargo build --release

FROM golang:1.21 as builder-go
ARG TARGETPLATFORM
Expand All @@ -18,5 +16,5 @@ COPY ./test/data ./test/data
RUN go mod download
COPY --from=builder-rust \
/workspace/target/release/libtokenizers.a \
/go/pkg/mod/github.com/daulet/tokenizers@v0.5.1/libtokenizers.a
RUN CGO_ENABLED=1 CGO_LDFLAGS="-Wl,--copy-dt-needed-entries" go run main.go
/go/pkg/mod/github.com/daulet/tokenizers@v0.6.0/libtokenizers.a
RUN go run main.go
2 changes: 1 addition & 1 deletion release/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/daulet/tokenizers/example

go 1.21

require github.com/daulet/tokenizers v0.5.1
require github.com/daulet/tokenizers v0.6.0
4 changes: 2 additions & 2 deletions release/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/daulet/tokenizers v0.5.1 h1:b8E1aUzssSq6Olm5YGJ+ZejtTJ0VHo2w98c1CNJsk6c=
github.com/daulet/tokenizers v0.5.1/go.mod h1:tGnMdZthXdcWY6DGD07IygpwJqiPvG85FQUnhs/wSCs=
github.com/daulet/tokenizers v0.6.0 h1:y6cSPx5YMrXy9dkt7NGWY1l64iwOpD0YU4j6P1Gwqo8=
github.com/daulet/tokenizers v0.6.0/go.mod h1:tGnMdZthXdcWY6DGD07IygpwJqiPvG85FQUnhs/wSCs=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down

0 comments on commit c2f743b

Please sign in to comment.