-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
54 lines (40 loc) · 1.4 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Use generic base image with Nix installed
FROM nixos/nix:2.20.5 AS env
# Configure Nix
RUN echo "extra-experimental-features = nix-command flakes" >> /etc/nix/nix.conf
# Set working directory to something other than root
WORKDIR /env/
# Copy Nix files
COPY flake.lock *.nix ./
# Copy env script
COPY scripts/env.sh scripts/env.sh
# Build runtime shell closure and activation script
RUN \
# Mount cached store paths
--mount=type=cache,target=/nix-store-cache/ \
# Mount Nix evaluation cache
--mount=type=cache,target=/root/.cache/nix/ \
./scripts/env.sh runtime build/ /nix-store-cache/
# Ubuntu is probably the safest choice for a runtime container right now
FROM ubuntu:23.10
# Use bash as default shell
SHELL ["/bin/bash", "-c"]
# Copy runtime shell closure and activation script
COPY --from=env /env/build/closure/ /nix/store/
COPY --from=env /env/build/activate /env/activate
# Set working directory to something other than root
WORKDIR /database/
# Create database user and data directory
RUN useradd --create-home database && \
mkdir --parents data/
# Setup entrypoint for RUN commands
COPY scripts/shell.sh scripts/shell.sh
SHELL ["/database/scripts/shell.sh"]
# Copy source
COPY src/ src/
# Setup main entrypoint
COPY scripts/entrypoint.sh scripts/entrypoint.sh
ENTRYPOINT ["/database/scripts/entrypoint.sh", "./src/start.sh"]
CMD []
# Setup ownership
RUN chown --recursive database: ./