Skip to content
Open

lab11 #1414

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
55 changes: 55 additions & 0 deletions .github/workflows/nix-repro.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Nix Reproducibility

on:
push:
branches: [ feature/lab11 ]
pull_request:
branches: [ main ]

jobs:
build1:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v31
with:
extra_nix_config: |
experimental-features = nix-command flakes
- run: nix build .#docker
- run: sha256sum result > digest1.txt
- uses: actions/upload-artifact@v4
with:
name: digest1
path: digest1.txt

build2:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v31
with:
extra_nix_config: |
experimental-features = nix-command flakes
- run: nix build .#docker
- run: sha256sum result > digest2.txt
- uses: actions/upload-artifact@v4
with:
name: digest2
path: digest2.txt

check:
runs-on: ubuntu-24.04
needs: [build1, build2]
steps:
- uses: actions/download-artifact@v4
with:
name: digest1
- uses: actions/download-artifact@v4
with:
name: digest2
- run: |
if [ "$(cat digest1.txt)" != "$(cat digest2.txt)" ]; then
echo "Digests differ!"
exit 1
fi
echo "Digests match!"
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM golang:1.24-alpine AS builder
WORKDIR /build
COPY app/go.mod ./
RUN go mod download
COPY app/ .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -ldflags="-s -w" -trimpath \
-o /build/quicknotes .

# ╨б╨╛╨╖╨┤╨░╤С╨╝ ╨┐╨░╨┐╨║╤Г /data ╨╕ ╨┤╨░╤С╨╝ ╨┐╤А╨░╨▓╨░ ╨▓ builder
RUN mkdir -p /data && chown 65532:65532 /data

FROM gcr.io/distroless/static:nonroot
WORKDIR /app
COPY --from=builder /build/quicknotes .
COPY --from=builder /data /data
COPY app/seed.json .
EXPOSE 8080
ENTRYPOINT ["/app/quicknotes"]
1 change: 1 addition & 0 deletions data/notes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 69 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
description = "QuickNotes - a small Go notes API";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
# Явно используем Go 1.24
go = pkgs.go_1_24;
in
{
packages.default = pkgs.buildGoModule {
pname = "quicknotes";
version = "0.1.0";

src = ./app;

vendorHash = null;
subPackages = [ "." ];

ldflags = [ "-s" "-w" ];

env = {
CGO_ENABLED = "0";
};

meta = {
description = "QuickNotes - a small Go notes API";
license = pkgs.lib.licenses.mit;
};
};

packages.quicknotes = self.packages.${system}.default;

packages.docker = pkgs.dockerTools.buildImage {
name = "quicknotes";
tag = "latest";

contents = [
pkgs.cacert
pkgs.busybox
];

config = {
Cmd = [ "${self.packages.${system}.quicknotes}/bin/quicknotes" ];
Env = [
"SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt"
];
ExposedPorts = {
"8080/tcp" = {};
};
};
};

devShell = pkgs.mkShell {
buildInputs = [
go
pkgs.gopls
pkgs.golangci-lint
];
};
}
);
}
Binary file added submissions/image-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added submissions/image-10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added submissions/image-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added submissions/image-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added submissions/image-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added submissions/image-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added submissions/image-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added submissions/image-7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added submissions/image-8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added submissions/image-9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added submissions/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading