Skip to content

Commit

Permalink
Merge pull request #30 from curieo-org/docker-fixes
Browse files Browse the repository at this point in the history
Docker fixes
  • Loading branch information
AsmiKloud authored Apr 11, 2024
2 parents 54f2e4a + 68307a9 commit 8a75880
Show file tree
Hide file tree
Showing 7 changed files with 257 additions and 14 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/build_docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Build Docker Image

on:
push:
branches:
- docker-fixes

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Build Docker Image
run: docker build -t curieo/search-rustserver:latest server/
4 changes: 2 additions & 2 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# pull official base image
FROM python:3.11-slim
FROM python:3.11.8-slim

# install system dependencies
RUN apt-get update && apt-get -y install libpq-dev gcc
RUN apt-get update && apt-get -y install libpq-dev gcc git


# install python dependencies
Expand Down
3 changes: 0 additions & 3 deletions server/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,3 @@ target/

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# These will be created by the sqlx CLI
*.sqlx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 20 additions & 9 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,38 @@
FROM lukemathwalker/cargo-chef:latest-rust-1.77-slim-bookworm as chef
WORKDIR /app
FROM rust:1.77 AS planner
WORKDIR app

FROM chef AS planner
RUN cargo install cargo-chef
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
RUN cargo chef prepare --recipe-path recipe.json

FROM chef AS builder
RUN apt-get update -y && apt-get install -y make perl
FROM rust:1.77 AS cacher
WORKDIR app
RUN cargo install cargo-chef
COPY --from=planner /app/recipe.json recipe.json
# Build our project dependencies, not our application!
RUN cargo chef cook --release --recipe-path recipe.json

FROM rust:1.77 AS builder
WORKDIR app
COPY --from=cacher /app/target target
COPY --from=cacher /usr/local/cargo /usr/local/cargo
COPY . .
ENV SQLX_OFFLINE true
RUN cargo build --release --bin server

FROM debian:bookworm-slim AS runtime
WORKDIR /app
WORKDIR app
COPY config config
COPY --from=builder /app/target/release/server /usr/local/bin
COPY ./config ./config
RUN apt-get update -y \
&& apt-get install -y --no-install-recommends openssl \
# Clean up
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*

RUN useradd -u 1000 server

USER server

EXPOSE 3030

CMD ["server"]
ENTRYPOINT ["/usr/local/bin/server"]

0 comments on commit 8a75880

Please sign in to comment.