Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker fixes #30

Merged
merged 5 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]