quectocraft2/Dockerfile

61 lines
1.9 KiB
Text
Raw Permalink Normal View History

2023-08-11 03:14:09 +00:00
# Dockerfile using debian to compile quectocraft
# Author: Tyler Murphy <tylerm.dev>
# How to run:
# With the working directory set to the root of this repository,
# run the following shell command
# docker build -f Dockerfile -t quectocraft .
#
# If you wish to run this in docker compose, it is already set
# to build the Docker file. Therefore you can just run
# docker compose up -d
##### Build Environment #####
# Used for building not for deployment
# This is includes rustc which isnt needed for production
# Use debian buster because its LTS and stable :3
FROM rust:buster as builder
WORKDIR /usr/src/quectocraft
# Copy over the rust files and source code for quectocraft
# Cargo.lock is needed because we dont want it updating packages
# on different peoples system
COPY ./Cargo.toml ./Cargo.toml
COPY ./Cargo.lock ./Cargo.lock
COPY ./src ./src
# Make sure libluajit-dev is installed so that the mlua rust crate
# can compile
RUN apt-get update && \
apt-get install -y libluajit-5.1-dev && \
rm -rf /var/lib/apt/lists/*
# Compile the program in into the containers local bin folder
RUN cargo install --path .
##### Production Environment #####
# Mininimal container environment while still allowing dependcies
# to work. Had issues compiling and running on alpine, so we are
# using debian here.
FROM debian:buster-slim
# Copy over the the binary from the builder envirnment
COPY --from=builder /usr/local/cargo/bin/quectocraft /usr/local/bin/quectocraft
# Again make sure libluajit is installed, though we dont need the dev
# version as headers are only needed when building
RUN apt-get update && \
apt-get install -y libluajit-5.1 && \
rm -rf /var/lib/apt/lists/*
# Create the working directory for quectocraft, this is where the plugin folder
# will be stored
RUN mkdir /data
VOLUME /data
WORKDIR /data
# Run quectocraft
CMD ["/usr/local/bin/quectocraft"]