dotnet / dotnet-docker

Docker images for .NET and the .NET Tools.
https://hub.docker.com/_/microsoft-dotnet
MIT License
4.48k stars 1.94k forks source link

Lambda package on Linux container results in "Failed to find the "zip" utility program in path. This program is required to maintain Linux file permissions in the zip archive." #409

Closed mrserverless closed 6 years ago

mrserverless commented 6 years ago

Steps to reproduce the issue

  1. Shell into any dotnet linux container, i.e: docker run -w /app -v $PWD:/app -ti microsoft/dotnet:2.0-sdk /bin/bash
  2. Run Lambda package command: dotnet lambda package --configuration release --framework netcoreapp2.0 --output-package bin/release/netcoreapp2.0/deploy-package.zip
  3. Sample code available here: https://github.com/serverless/serverless/tree/master/lib/plugins/create/templates/aws-fsharp with docker-compose: https://github.com/serverless/serverless/blob/master/docker-compose.yml

Expected behavior

Successful package:

Changed permissions on published dll (chmod +r Newtonsoft.Json.dll).
Zipping publish folder /app/bin/release/netcoreapp2.0/publish to /app/bin/release/netcoreapp2.0/deploy-package.zip
... zipping:   adding: Amazon.Lambda.Core.dll (deflated 57%)
... zipping:   adding: Newtonsoft.Json.dll (deflated 60%)
Created publish archive (/app/bin/release/netcoreapp2.0/deploy-package.zip).
Lambda project successfully packaged: /app/bin/release/netcoreapp2.0/deploy-package.zip

Actual behavior

Failure to find zip:

Changed permissions on published dll (chmod +r Newtonsoft.Json.dll).
Zipping publish folder /app/bin/release/netcoreapp2.0/publish to /app/bin/release/netcoreapp2.0/deploy-package.zip
Failed to find the "zip" utility program in path. This program is required to maintain Linux file permissions in the zip archive.

Additional information (e.g. issue happens only occasionally)

Basically to work around this, I need to

  1. Install zip myself with apt -y install zip first OR
  2. Create a separate docker image inheriting from dotnet-sdk:2.0 and install zip

zip command should be part of this image in order to support the dotnet commands that are offered.

Output of docker version

Client:
 Version:       17.12.0-ce
 API version:   1.35
 Go version:    go1.9.2
 Git commit:    c97c6d6
 Built: Wed Dec 27 20:11:19 2017
 OS/Arch:       linux/amd64

Server:
 Engine:
  Version:      17.12.0-ce
  API version:  1.35 (minimum version 1.12)
  Go version:   go1.9.2
  Git commit:   c97c6d6
  Built:        Wed Dec 27 20:12:29 2017
  OS/Arch:      linux/amd64
  Experimental: true

Output of docker info

Containers: 103
 Running: 1
 Paused: 0
 Stopped: 102
Images: 72
Server Version: 17.12.0-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: active
 NodeID: fauuc0mazqvxjoyktkxsrz1sk
 Is Manager: true
 ClusterID: oh3h7c73uk2lrwe83odqa0yvp
 Managers: 1
 Nodes: 1
 Orchestration:
  Task History Retention Limit: 5
 Raft:
  Snapshot Interval: 10000
  Number of Old Snapshots to Retain: 0
  Heartbeat Tick: 1
  Election Tick: 3
 Dispatcher:
  Heartbeat Period: 5 seconds
 CA Configuration:
  Expiry Duration: 3 months
  Force Rotate: 0
 Autolock Managers: false
 Root Rotation In Progress: false
 Node Address: 10.142.0.2
 Manager Addresses:
  10.142.0.2:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 89623f28b87a6004d4b785663257362d1658a729
runc version: b2567b37d7b75eb4cf325b77297b140ea686ce8f
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.60-linuxkit-aufs
Operating System: Docker for Windows
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934GiB
Name: linuxkit-00155d000b1d
ID: KJRI:PL6I:Z443:ZUFA:OS5M:JDGM:RPHC:HXGG:AIQF:7HNH:MOIP:UF6C
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 46
 Goroutines: 169
 System Time: 2018-03-03T11:40:10.981461Z
 EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
mrserverless commented 6 years ago

Closing since this is addressed in a more appropriate PR https://github.com/aws/aws-lambda-dotnet/pull/238

SangI762 commented 1 year ago

@mrserverless, hey, I'm still getting this error when running lambda package on .net6 image. I need a lambda zip package. How can I achieve that?

olevezinho commented 10 months ago

Not sure if this might help @SangI762, @mrserverless. For future reference, this is basically Linux / macOS complaining about the non-existence of "zip" binaries. Most Linux distros come with unzip utility installed by default, but they don't contain the "zip" utility. Install that, and you should be fine.