Skip to content

Commit

Permalink
Update release profile, fix Docker images (they actually work!)
Browse files Browse the repository at this point in the history
  • Loading branch information
auguwu committed Oct 18, 2024
1 parent 37ca4d7 commit f01e0c9
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 51 deletions.
14 changes: 14 additions & 0 deletions Cargo.lock

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

10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ git = "https://github.com/Noelware/azalia"
rev = "a08c495a81b37ea6684c94d8b6c67f32b37b67e1"

[profile.release]
opt-level = "z"
strip = true
debug = 0
lto = "thin"
codegen-units = 1 # use a single codegen unit
opt-level = "s" # optimize for size
panic = "abort" # abort the process when a panic occurs
strip = true # strip all debug symbols
debug = 0 # disable debug information
lto = true # perform LTO on all crates (even our own)
8 changes: 8 additions & 0 deletions crates/bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,21 @@ publish.workspace = true
repository.workspace = true
authors.workspace = true

[features]
default = []

bundled-pq = ["dep:pq-sys", "pq-sys/bundled"]
bundled-sqlite = ["dep:libsqlite3-sys", "libsqlite3-sys/bundled"]

[dependencies]
charted-cli = { version = "0.1.0", path = "../cli" }
charted-core.workspace = true
clap.workspace = true
color-eyre = { version = "0.6.3", features = ["issue-url"] }
dotenvy = "0.15.7"
eyre.workspace = true
libsqlite3-sys = { version = "0.30.1", optional = true }
mimalloc = "0.1.43"
num_cpus = "1.16.0"
pq-sys = { version = "0.6.3", optional = true }
tokio = { workspace = true, features = ["rt", "rt-multi-thread"] }
11 changes: 3 additions & 8 deletions distribution/charted/docker/alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ RUN apk upgrade && apk add --no-cache \
gcompat \
pkgconfig \
openssl-dev \
build-base \
sqlite-dev \
postgresql-dev
build-base

WORKDIR /build
COPY . .
Expand All @@ -37,18 +35,15 @@ COPY . .
RUN rm rust-toolchain.toml

ENV RUSTFLAGS="--cfg tokio_unstable -C link-arg=-fuse-ld=mold -Ctarget-cpu=native -Ctarget-feature=-crt-static"
RUN cargo build --locked --release --package charted
RUN cargo build --locked --release --package charted --features bundled-sqlite --features bundled-pq

##### FINAL STAGE
FROM alpine:3.20

RUN apk upgrade && apk add --no-cache \
bash \
tini \
curl \
libgcc \
sqlite-dev \
postgresql-dev
curl

WORKDIR /app/noelware/charted/server

Expand Down
76 changes: 37 additions & 39 deletions distribution/charted/docker/debian.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,55 +16,53 @@
###### BINARY BUILD
FROM rustlang/rust:nightly-bookworm-slim AS build

# ENV DEBIAN_FRONTEND=noninteractive
# RUN apt update && \
# apt upgrade -y && \
# apt install -y --no-install-recommends \
# git \
# mold \
# ca-certificates \
# libssl-dev \
# build-essential \
# pkg-config \
# libpq5 \
# libsqlite3-0
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && \

Check failure on line 20 in distribution/charted/docker/debian.Dockerfile

View workflow job for this annotation

GitHub Actions / Hadolint [./distribution/charted/docker/debian.Dockerfile]

DL3027 warning: Do not use apt as it is meant to be a end-user tool, use apt-get or apt-cache instead
apt upgrade -y && \
apt install -y --no-install-recommends \
git \
mold \
ca-certificates \
libssl-dev \
build-essential \
pkg-config

# WORKDIR /build
# COPY . .
WORKDIR /build
COPY . .

# # We want to use the Nightly version of Rust from the image itself, not what we
# # defined in `rust-toolchain.toml`.
# RUN rm rust-toolchain.toml
# We want to use the Nightly version of Rust from the image itself, not what we
# defined in `rust-toolchain.toml`.
RUN rm rust-toolchain.toml

# ENV RUSTFLAGS="--cfg tokio_unstable -C link-arg=-fuse-ld=mold -Ctarget-cpu=native"
# RUN cargo build --locked --release --package charted
ENV RUSTFLAGS="--cfg tokio_unstable -C link-arg=-fuse-ld=mold -Ctarget-cpu=native"
RUN cargo build --locked --release --package charted --features bundled-sqlite --features bundled-pq

##### FINAL STAGE
FROM debian:bookworm-slim

# RUN apt update && apt upgrade -y && apt install -y bash tini curl libssl-dev pkg-config libpq5 libsqlite3-0
RUN apt update && apt upgrade -y && apt install -y bash tini curl libssl-dev

Check failure on line 43 in distribution/charted/docker/debian.Dockerfile

View workflow job for this annotation

GitHub Actions / Hadolint [./distribution/charted/docker/debian.Dockerfile]

DL3027 warning: Do not use apt as it is meant to be a end-user tool, use apt-get or apt-cache instead

# WORKDIR /app/noelware/charted/server
WORKDIR /app/noelware/charted/server

# COPY --from=build /build/target/release/charted /app/noelware/charted/server/bin/charted
# COPY distribution/charted/docker/scripts /app/noelware/charted/server/scripts
# COPY distribution/charted/docker/config /app/noelware/charted/server/config
COPY --from=build /build/target/release/charted /app/noelware/charted/server/bin/charted
COPY distribution/charted/docker/scripts /app/noelware/charted/server/scripts
COPY distribution/charted/docker/config /app/noelware/charted/server/config

# ENV CHARTED_DISTRIBUTION_TYPE=docker
# EXPOSE 3651
# VOLUME /var/lib/noelware/charted/data
ENV CHARTED_DISTRIBUTION_TYPE=docker
EXPOSE 3651
VOLUME /var/lib/noelware/charted/data

# RUN mkdir -p /var/lib/noelware/charted/data
# RUN groupadd -g 1001 noelware && \
# useradd -rm -s /bin/bash -g noelware -u 1001 noelware && \
# chown noelware:noelware /app/noelware/charted/server && \
# chown noelware:noelware /var/lib/noelware/charted/data && \
# chmod +x /app/noelware/charted/server/scripts/docker-entrypoint.sh
RUN mkdir -p /var/lib/noelware/charted/data
RUN groupadd -g 1001 noelware && \
useradd -rm -s /bin/bash -g noelware -u 1001 noelware && \
chown noelware:noelware /app/noelware/charted/server && \
chown noelware:noelware /var/lib/noelware/charted/data && \
chmod +x /app/noelware/charted/server/scripts/docker-entrypoint.sh

# # Create a symbolic link so you can just run `charted` without specifying
# # the full path.
# RUN ln -s /app/noelware/charted/server/bin/charted /usr/bin/charted
# Create a symbolic link so you can just run `charted` without specifying
# the full path.
RUN ln -s /app/noelware/charted/server/bin/charted /usr/bin/charted

# USER noelware
# ENTRYPOINT ["/app/noelware/charted/server/scripts/docker-entrypoint.sh"]
# CMD ["/app/noelware/charted/server/bin/charted", "server"]
USER noelware
ENTRYPOINT ["/app/noelware/charted/server/scripts/docker-entrypoint.sh"]
CMD ["/app/noelware/charted/server/bin/charted", "server"]

0 comments on commit f01e0c9

Please sign in to comment.