Image now builds and runs 🎉 Thx to the help of yzhr
This commit is contained in:
parent
a21858758c
commit
ecb6416244
2 changed files with 19 additions and 49 deletions
66
Dockerfile
66
Dockerfile
|
@ -4,43 +4,23 @@
|
||||||
|
|
||||||
|
|
||||||
########################## BUILD IMAGE ##########################
|
########################## BUILD IMAGE ##########################
|
||||||
# Musl build image to build Conduits statically compiled binary
|
# Alpine build image to build Conduits statically compiled binary
|
||||||
FROM rustlang/rust:nightly-alpine3.12 as builder
|
FROM alpine:3.12 as builder
|
||||||
|
|
||||||
# Don't download Rust docs
|
# Add 'edge'-repository to get Rust 1.45
|
||||||
RUN rustup set profile minimal
|
RUN sed -i \
|
||||||
|
-e 's|v3\.12|edge|' \
|
||||||
ENV USER "conduit"
|
/etc/apk/repositories
|
||||||
#ENV RUSTFLAGS='-C link-arg=-s'
|
|
||||||
|
|
||||||
# Install packages needed for building all crates
|
# Install packages needed for building all crates
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
musl-dev \
|
cargo \
|
||||||
openssl-dev \
|
openssl-dev
|
||||||
pkgconf
|
|
||||||
|
|
||||||
# Create dummy project to fetch all dependencies.
|
# Copy project from current folder and build it
|
||||||
# Rebuilds are a lot faster when there are no changes in the
|
|
||||||
# dependencies.
|
|
||||||
RUN cargo new --bin /app
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
# Copy cargo files which specify needed dependencies
|
|
||||||
COPY ./Cargo.* ./
|
|
||||||
|
|
||||||
# Add musl target, as we want to run your project in
|
|
||||||
# an alpine linux image
|
|
||||||
RUN rustup target add x86_64-unknown-linux-musl
|
|
||||||
|
|
||||||
# Build dependencies and remove dummy project, except
|
|
||||||
# target folder, as it contains the dependencies
|
|
||||||
RUN cargo build --release --color=always ; \
|
|
||||||
find . -not -path "./target*" -delete
|
|
||||||
|
|
||||||
# Now copy and build the real project with the pre-built
|
|
||||||
# dependencies.
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN cargo build --release --color=always
|
RUN cargo install --path .
|
||||||
|
#RUN cargo install --git "https://git.koesters.xyz/timo/conduit.git"
|
||||||
|
|
||||||
########################## RUNTIME IMAGE ##########################
|
########################## RUNTIME IMAGE ##########################
|
||||||
# Create new stage with a minimal image for the actual
|
# Create new stage with a minimal image for the actual
|
||||||
|
@ -68,26 +48,15 @@ LABEL org.opencontainers.image.created=${CREATED} \
|
||||||
org.label-schema.docker.build="docker build . -t conduit:latest --build-arg CREATED=$(date -u +'%Y-%m-%dT%H:%M:%SZ') --build-arg VERSION=$(grep -m1 -o '[0-9].[0-9].[0-9]' Cargo.toml)"\
|
org.label-schema.docker.build="docker build . -t conduit:latest --build-arg CREATED=$(date -u +'%Y-%m-%dT%H:%M:%SZ') --build-arg VERSION=$(grep -m1 -o '[0-9].[0-9].[0-9]' Cargo.toml)"\
|
||||||
maintainer="weasy@hotmail.de"
|
maintainer="weasy@hotmail.de"
|
||||||
|
|
||||||
# Change some Rocket.rs default configs. They can then
|
|
||||||
# be changed to different values using env variables.
|
|
||||||
ENV ROCKET_CLI_COLORS="on"
|
|
||||||
#ENV ROCKET_SERVER_NAME="conduit.rs"
|
|
||||||
ENV ROCKET_ENV="production"
|
|
||||||
ENV ROCKET_ADDRESS=0.0.0.0
|
|
||||||
ENV ROCKET_PORT=14004
|
|
||||||
ENV ROCKET_LOG="normal"
|
|
||||||
ENV ROCKET_DATABASE_PATH="/data/sled"
|
|
||||||
ENV ROCKET_REGISTRATION_DISABLED="true"
|
|
||||||
#ENV ROCKET_WORKERS=10
|
|
||||||
|
|
||||||
EXPOSE 14004
|
EXPOSE 14004
|
||||||
|
|
||||||
# Copy config files from context and the binary from
|
# Copy config files from context and the binary from
|
||||||
# the "builder" stage to the current stage into folder
|
# the "builder" stage to the current stage into folder
|
||||||
# /srv/conduit and create data folder for database
|
# /srv/conduit and create data folder for database
|
||||||
RUN mkdir -p /srv/conduit /data/sled
|
RUN mkdir -p /srv/conduit/.local/share/conduit
|
||||||
|
|
||||||
COPY --from=builder /app/target/release/conduit ./srv/conduit/
|
COPY --from=builder /root/.cargo/bin/conduit /srv/conduit/
|
||||||
|
|
||||||
# Add www-data user and group with UID 82, as used by alpine
|
# Add www-data user and group with UID 82, as used by alpine
|
||||||
# https://git.alpinelinux.org/aports/tree/main/nginx/nginx.pre-install
|
# https://git.alpinelinux.org/aports/tree/main/nginx/nginx.pre-install
|
||||||
|
@ -97,12 +66,13 @@ RUN set -x ; \
|
||||||
addgroup www-data www-data 2>/dev/null && exit 0 ; exit 1
|
addgroup www-data www-data 2>/dev/null && exit 0 ; exit 1
|
||||||
|
|
||||||
# Change ownership of Conduit files to www-data user and group
|
# Change ownership of Conduit files to www-data user and group
|
||||||
RUN chown -cR www-data:www-data /srv/conduit /data
|
RUN chown -cR www-data:www-data /srv/conduit
|
||||||
|
|
||||||
VOLUME /data
|
|
||||||
|
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
ca-certificates
|
ca-certificates \
|
||||||
|
libgcc
|
||||||
|
|
||||||
|
VOLUME ["/srv/conduit/.local/share/conduit"]
|
||||||
|
|
||||||
# Set user to www-data
|
# Set user to www-data
|
||||||
USER www-data
|
USER www-data
|
||||||
|
|
|
@ -8,7 +8,7 @@ services:
|
||||||
ports:
|
ports:
|
||||||
- 14004:14004
|
- 14004:14004
|
||||||
volumes:
|
volumes:
|
||||||
- db:/data/sled
|
- db:/srv/conduit/.local/share/conduit
|
||||||
environment:
|
environment:
|
||||||
ROCKET_SERVER_NAME: example.com # replace with your own name
|
ROCKET_SERVER_NAME: example.com # replace with your own name
|
||||||
### Uncomment and change values as needed
|
### Uncomment and change values as needed
|
||||||
|
|
Loading…
Add table
Reference in a new issue