Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nix docker #19

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/registry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

name: "Docker Registry Push"
on:
push:
tags: ['*']

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v18
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v11
with:
name: fleetbot
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: nix build -L .#ex_fleet_yards_docker
- name: "Import and Push image"
run: |
docker load < result
docker tag exfleetyards:latest ghcr.io/fleetyards/exfleetyards:latest
docker tag exfleetyards:latest ghcr.io/fleetyards/exfleetyards:${{ github.ref_name }}
docker push ghcr.io/fleetyards/exfleetyards:latest
docker push ghcr.io/fleetyards/exfleetyards:${{ github.ref_name }}
27 changes: 25 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
nixpkgsFor = forAllSystems (system:
import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
overlays = [ self.overlays.default self.overlays.docker ];
});
in {
overlays.fleet = final: prev: {
Expand Down Expand Up @@ -77,10 +77,33 @@
nativeBuildInputs = [ rebar3 ];
}) { };
};
overlays.docker = final: prev: {
ex_fleet_yards_docker = final.callPackage
({ lib, ex_fleet_yards, dockerTools, buildEnv }:
dockerTools.buildImage {
name = "ExFleetYards";
tag = "latest";

copyToRoot = buildEnv {
name = "ex_fleet_yards-root";
paths = [ ex_fleet_yards ];
pathsToLink = [ "/bin" ];
};

config = {
Entrypoint = [ "/bin/ex_fleet_yards_web" ];
Cmd = [ "start" ];
ExposedPorts."4000/tcp" = { };
Env = [ "FLEETYARDS_CONFIG_PATH=/config/config.exs" ];
Volumes."/config/" = { };
};
}) { };
};
overlays.default = self.overlays.fleet;

packages = forAllSystems (system: {
inherit (nixpkgsFor.${system}) ex_fleet_yards appsignal_nif;
inherit (nixpkgsFor.${system})
ex_fleet_yards appsignal_nif ex_fleet_yards_docker;
default = self.packages.${system}.ex_fleet_yards;
});

Expand Down