mirror of
https://git.asonix.dog/asonix/pict-rs.git
synced 2024-11-24 18:41:06 +00:00
Alter docker dev to create rust environment
This commit is contained in:
parent
044c34f27f
commit
d2627d6b8f
4 changed files with 34 additions and 84 deletions
23
README.md
23
README.md
|
@ -44,20 +44,23 @@ $ ./pict-rs -a 127.0.0.1:8080 -p data/ -w thumbnail identity
|
|||
Run the following commands:
|
||||
```
|
||||
# Create a folder for the files (anywhere works)
|
||||
mkdir ./pict-rs
|
||||
cd ./pict-rs
|
||||
mkdir -p volumes/pictrs
|
||||
sudo chown -R 991:991 volumes/pictrs
|
||||
wget https://git.asonix.dog/asonix/pict-rs/raw/branch/master/docker/prod/docker-compose.yml
|
||||
sudo docker-compose up -d
|
||||
$ mkdir ./pict-rs
|
||||
$ cd ./pict-rs
|
||||
$ mkdir -p volumes/pictrs
|
||||
$ sudo chown -R 991:991 volumes/pictrs
|
||||
$ wget https://git.asonix.dog/asonix/pict-rs/raw/branch/master/docker/prod/docker-compose.yml
|
||||
$ sudo docker-compose up -d
|
||||
```
|
||||
|
||||
#### Docker Development
|
||||
Run the following to develop in docker:
|
||||
The development system loads a rust environment inside a docker container with the neccessary
|
||||
dependencies already present
|
||||
```
|
||||
git clone https://git.asonix.dog/asonix/pict-rs
|
||||
cd pict-rs/docker/dev
|
||||
./dev.sh
|
||||
$ git clone https://git.asonix.dog/asonix/pict-rs
|
||||
$ cd pict-rs/docker/dev
|
||||
$ ./dev.sh
|
||||
$ cargo build
|
||||
$ cargo run
|
||||
```
|
||||
|
||||
### API
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
# Target environment
|
||||
FROM amd64/ubuntu:20.04 as target-env
|
||||
|
||||
ENV \
|
||||
TARGET=x86_64-unknown-linux-gnu \
|
||||
BUILD_MODE=release
|
||||
|
||||
# Basic cross-build environment
|
||||
FROM ubuntu:20.04 as cross-build
|
||||
|
||||
ARG UID=1000
|
||||
ARG GID=1000
|
||||
|
||||
ENV \
|
||||
ARCH=amd64 \
|
||||
HOST=x86_64-unknown-linux \
|
||||
|
@ -32,12 +28,12 @@ ENV \
|
|||
RUN \
|
||||
sed 's/http:\/\/\(.*\).ubuntu.com\/ubuntu\//[arch-=amd64,i386] http:\/\/ports.ubuntu.com\/ubuntu-ports\//g' /etc/apt/sources.list > /etc/apt/sources.list.d/ports.list && \
|
||||
sed -i 's/http:\/\/\(.*\).ubuntu.com\/ubuntu\//[arch=amd64,i386] http:\/\/\1.archive.ubuntu.com\/ubuntu\//g' /etc/apt/sources.list && \
|
||||
addgroup --gid 991 build && \
|
||||
addgroup --gid $GID build && \
|
||||
adduser \
|
||||
--disabled-password \
|
||||
--gecos "" \
|
||||
--ingroup build \
|
||||
--uid 991 \
|
||||
--uid $UID \
|
||||
--home /opt/build \
|
||||
build && \
|
||||
dpkg --add-architecture $ARCH && \
|
||||
|
@ -129,7 +125,13 @@ RUN \
|
|||
libltdl7:$ARCH \
|
||||
llvm-dev \
|
||||
libclang-dev \
|
||||
clang
|
||||
clang \
|
||||
libpng16-16:$ARCH \
|
||||
libjpeg8:$ARCH \
|
||||
libwebp6:$ARCH \
|
||||
libwebpdemux2:$ARCH \
|
||||
libwebpmux3:$ARCH \
|
||||
libgomp1:$ARCH
|
||||
|
||||
ENV \
|
||||
PATH=$PATH:/opt/build/.cargo/bin \
|
||||
|
@ -149,64 +151,7 @@ COPY --from=imagemagick-builder /usr/local/ /usr/local
|
|||
|
||||
USER build
|
||||
|
||||
WORKDIR /opt/build
|
||||
|
||||
RUN \
|
||||
USER=build cargo new repo
|
||||
mkdir -p /opt/build/repo
|
||||
|
||||
WORKDIR /opt/build/repo
|
||||
|
||||
COPY --chown=build:build Cargo.toml Cargo.lock ./
|
||||
|
||||
RUN \
|
||||
mkdir -p ./src && \
|
||||
echo 'fn main() { println!("Dummy") }' > ./src/main.rs && \
|
||||
USER=build cargo build --$BUILD_MODE && \
|
||||
rm -rf ./src && \
|
||||
rm -rf ./target/$BUILD_MODE/deps/pict_rs-*
|
||||
|
||||
COPY --chown=build:build src ./src/
|
||||
|
||||
RUN \
|
||||
cargo build --$BUILD_MODE --frozen
|
||||
|
||||
# Producing target binary
|
||||
FROM target-env
|
||||
|
||||
ARG UID=991
|
||||
ARG GID=991
|
||||
|
||||
RUN \
|
||||
addgroup --gid $GID pictrs && \
|
||||
adduser \
|
||||
--disabled-password \
|
||||
--gecos "" \
|
||||
--ingroup pictrs \
|
||||
--uid $UID \
|
||||
--home /opt/pict-rs \
|
||||
pictrs && \
|
||||
apt-get update && \
|
||||
apt-get upgrade -y && \
|
||||
apt-get install -y \
|
||||
libgexiv2-2 \
|
||||
libpng16-16 \
|
||||
libjpeg8 \
|
||||
libwebp6 \
|
||||
libwebpdemux2 \
|
||||
libwebpmux3 \
|
||||
libltdl7 \
|
||||
libgomp1 \
|
||||
libxml2 \
|
||||
tini
|
||||
|
||||
COPY --from=pict-rs-builder /opt/build/repo/target/$BUILD_MODE/pict-rs /usr/local/bin/pict-rs
|
||||
COPY --from=imagemagick-builder /usr/local /usr/local
|
||||
|
||||
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
|
||||
|
||||
VOLUME /mnt
|
||||
WORKDIR /opt/pict-rs
|
||||
USER pictrs
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["/usr/bin/tini", "--"]
|
||||
CMD ["/usr/local/bin/pict-rs", "-p", "/mnt"]
|
||||
|
|
|
@ -5,4 +5,5 @@ export GROUP_ID=$(id -g)
|
|||
|
||||
mkdir -p ./volumes/pictrs
|
||||
|
||||
docker-compose up --build
|
||||
docker-compose build --pull
|
||||
docker-compose run --service-ports pictrs
|
||||
|
|
|
@ -3,15 +3,16 @@ version: '3.3'
|
|||
services:
|
||||
pictrs:
|
||||
build:
|
||||
context: ../../
|
||||
dockerfile: docker/dev/Dockerfile
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
UID: "${USER_ID:-1000}"
|
||||
GID: "${GROUP_ID:-1000}"
|
||||
ports:
|
||||
- "127.0.0.1:8080:8080"
|
||||
restart: always
|
||||
- "8080:8080"
|
||||
stdin_open: true
|
||||
tty: true
|
||||
environment:
|
||||
- RUST_LOG=info,pict_rs=debug
|
||||
volumes:
|
||||
- ./volumes/pictrs:/mnt
|
||||
- ../../:/opt/build/repo
|
||||
|
|
Loading…
Reference in a new issue