mirror of
https://github.com/mCaptcha/cache.git
synced 2024-11-22 00:25:20 +03:00
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:
parent
83448fd0fb
commit
4ad44b39b3
3 changed files with 22 additions and 26 deletions
29
.github/workflows/linux.yml
vendored
29
.github/workflows/linux.yml
vendored
|
@ -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'
|
||||
|
|
11
Dockerfile
11
Dockerfile
|
@ -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"]
|
||||
|
|
8
Makefile
8
Makefile
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue