Fixes #2: fix docker builds

Docker layer caching broke the build. target/release/libcache.so that
was copied over from "builder" stage img was the result of the first
stage of compilation(dependencies only and no source code)

So the object file didn't contain anything that resembled this repo's source
code.

This patch employs a slightly modified caching technique(see Dockerfile)
which fixes the issue
This commit is contained in:
realaravinth 2021-12-16 14:51:51 +05:30
parent 83448fd0fb
commit 4ad44b39b3
No known key found for this signature in database
GPG key ID: AD9F0F08E855ED88
3 changed files with 22 additions and 26 deletions

View file

@ -37,22 +37,23 @@ jobs:
profile: minimal
override: false
# - name: install virtualenv
# run: pip install virtualenv
#
# - name: install dependencies
# run: make env
# # - name: build docker image
# run: make docker-build
#
#- name: start docker container
# run: make docker-run
- name: install virtualenv
run: pip install virtualenv
#- name: run tests
# run: make test
- name: install dependencies
run: make env
#- name: stop docker container
# run: make docker-stop
- name: build docker image
run: make docker-build
- name: start docker container
run: make docker-run
- name: run tests
run: make test
- name: stop docker container
run: make docker-stop
- name: Login to DockerHub
if: (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'mCaptcha/cache'

View file

@ -13,15 +13,13 @@ RUN set -ex; \
DEBIAN_FRONTEND=noninteractive \
apt-get install -y --no-install-recommends redis clang gcc
COPY Cargo.toml Cargo.lock /src/
RUN mkdir -p /src/src && touch /src/src/lib.rs
RUN cargo build --release
COPY . .
COPY src/lib.rs /src/src/lib.rs
RUN cargo build --release || true
COPY . /src/
RUN ls /src/src
RUN cargo build --release
#FROM redisfab/redis:${REDIS_VER}-${ARCH}-${OSNICK}
FROM redis:${REDIS_VER}-${OSNICK}
ARG REDIS_VER
ENV LIBDIR /usr/lib/redis/modules
@ -29,6 +27,5 @@ WORKDIR /data
RUN mkdir -p "$LIBDIR"
COPY --from=builder /src/target/release/libcache.so "$LIBDIR"
EXPOSE 6379
CMD ["redis-server", "--loadmodule", "/usr/lib/redis/modules/libcache.so"]

View file

@ -19,16 +19,14 @@ doc:
cargo doc --no-deps --workspace --all-features --document-private-items
docker:
docker build -t mcaptcha/cache:broken-build .
#docker build -t mcaptcha/cache:0.1.0-beta -t mcaptcha/cache:latest .
#docker push mcaptcha/cache:0.1.0-beta
docker push mcaptcha/cache:broken-build
docker build -t mcaptcha/cache:0.1.0-beta -t mcaptcha/cache:latest .
docker push mcaptcha/cache:0.1.0-beta
docker-build:
docker build -t mcaptcha/cache:0.1.0-beta -t mcaptcha/cache:latest .
docker-run:
docker run --name=$(DOCKER_CONTAINER) \
docker run -d --name=$(DOCKER_CONTAINER) \
--publish 6379:6379 \
mcaptcha/cache:latest