Skip to content

Commit

Permalink
chore: create Nix flake to use in Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
oxcabe committed Mar 19, 2024
1 parent b56460f commit 2365402
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 51 deletions.
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# syntax=docker/dockerfile:1.7

# Nix builder
FROM nixos/nix:latest AS builder

# Copy our source and setup our working dir
COPY . /tmp/build
WORKDIR /tmp/build

# Build our Nix environment
RUN nix \
--extra-experimental-features "nix-command flakes" \
--option filter-syscalls false \
build

# Copy the Nix store closure into a directory
RUN mkdir /tmp/nix-store-closure
RUN cp -R $(nix-store -qR result/) /tmp/nix-store-closure

# Final image
FROM scratch

WORKDIR /app

# Copy /nix/store
COPY --from=builder /tmp/nix-store-closure /nix/store
COPY --from=builder /tmp/build/result /app
CMD ["/app/bin/app"]
37 changes: 37 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
description = "simde";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
pnpm2nix = {
url = "github:nzbr/pnpm2nix-nzbr";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, flake-utils, pnpm2nix, ... } @ inputs:
flake-utils.lib.eachDefaultSystem (system:
let pkgs = import nixpkgs { inherit system; };
in with pkgs; rec {
# Development environment
devShell = mkShell {
name = "simde";
nativeBuildInputs = [ nodejs nodePackages.pnpm ];
};

# Build package into dist/ dir with pnpm
dist = pnpm2nix.packages.${system}.mkPnpmPackage {
src = ./.;
};

# Create SIMDE dist/ + SWS bundle
packages.app = pkgs.writeShellScriptBin "app" ''
${pkgs.static-web-server}/bin/static-web-server --root ${dist}.distDir
'';

# The default package when a specific package name isn't specified
defaultPackage = packages.app;
}
);
}
35 changes: 0 additions & 35 deletions tools/Dockerfile

This file was deleted.

16 changes: 0 additions & 16 deletions tools/docker-nginx.conf

This file was deleted.

0 comments on commit 2365402

Please sign in to comment.