dokku / github-action

MIT License
163 stars 28 forks source link

How to add an extra file before pushing to dokku? #32

Closed d-e-v-esh closed 1 year ago

d-e-v-esh commented 1 year ago

Pushing to dokku through GitHub Actions is working as intended.

The Dockerfile in my project needs a .env.production file to work which is NOT available in the GitHub repo of the project because it contains sensitive information. To fix that problem, I tried to generate it on the fly in GitHub Actions before pushing it to Dokku but for some reason it is not working.

The .env.production file successfuly gets generated in the GitHub Actions.

image

But I think it is not being bundled with the files that are getting pushed to Dokku. Therefore, I'm getting the error that I will get if I run the Dockerfile without the .env.production file.

image

I couldn't file any solution to this in the docs. Any help will be really appreciated. ๐Ÿ™๐Ÿ™

This is how the workflow file looks:

name: Dokku CI

on:
  push:
    branches: [ "dev" ]

jobs:

  dokku:

    runs-on: ubuntu-latest

    steps:
    - name: Cloning Repository
      uses: actions/checkout@v3
      with:
        fetch-depth: 0

    - name: Create production env file
      env:
        SESSION_SECRET: ${{ secrets.SESSION_SECRET }}
      run : |
        touch .env.production
        echo CORS_ORIGIN=https://codeisscience.com >> .env.production
        echo SESSION_SECRET=$SESSION_SECRET >> .env.production

    - name: Push to Dokku
      uses: dokku/github-action@v1.3.0
      with:
        git_push_flags: '--force'
        git_remote_url: 'ssh://dokku@164.92.178.133:22/api'
        ssh_private_key: ${{ secrets.RSA_PRIVATE_KEY }}

dokku report APP_NAME output

Click me ### Output ```bash -----> uname: Linux journal-policy 5.15.0-41-generic #44-Ubuntu SMP Wed Jun 22 14:20:53 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux -----> memory: total used free shared buff/cache available Mem: 971 315 80 1 575 466 Swap: 0 0 0 -----> docker version: Client: Docker Engine - Community Version: 20.10.18 API version: 1.41 Go version: go1.18.6 Git commit: b40c2f6 Built: Thu Sep 8 23:11:43 2022 OS/Arch: linux/amd64 Context: default Experimental: true Server: Docker Engine - Community Engine: Version: 20.10.18 API version: 1.41 (minimum version 1.12) Go version: go1.18.6 Git commit: e42327a Built: Thu Sep 8 23:09:30 2022 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.6.8 GitCommit: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6 runc: Version: 1.1.4 GitCommit: v1.1.4-0-g5fd4c4d docker-init: Version: 0.19.0 GitCommit: de40ad0 -----> docker daemon info: Client: Context: default Debug Mode: true Plugins: app: Docker App (Docker Inc., v0.9.1-beta3) buildx: Docker Buildx (Docker Inc., v0.9.1-docker) compose: Docker Compose (Docker Inc., v2.10.2) scan: Docker Scan (Docker Inc., v0.17.0) Server: Containers: 2 Running: 2 Paused: 0 Stopped: 0 Images: 15 Server Version: 20.10.18 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true userxattr: false Logging Driver: json-file Cgroup Driver: systemd Cgroup Version: 2 Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc Default Runtime: runc Init Binary: docker-init containerd version: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6 runc version: v1.1.4-0-g5fd4c4d init version: de40ad0 Security Options: apparmor seccomp Profile: default cgroupns Kernel Version: 5.15.0-41-generic Operating System: Ubuntu 22.04.1 LTS OSType: linux Architecture: x86_64 CPUs: 1 Total Memory: 971.1MiB Name: journal-policy-tracker-backend ID: ISY4:Y5CF:P6LW:GRNJ:DZS3:Y62B:EFM2:WHXN:3FXC:3ZPK:452M:BHAP Docker Root Dir: /var/lib/docker Debug Mode: false Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false -----> git version: git version 2.34.1 -----> sigil version: 0.9.0build+bc921b7 -----> herokuish version: herokuish: 0.5.37 buildpacks: heroku-buildpack-multi v1.2.0 heroku-buildpack-ruby v244 heroku-buildpack-nodejs v198 heroku-buildpack-clojure v90 heroku-buildpack-python v214 heroku-buildpack-java v72 heroku-buildpack-gradle v38 heroku-buildpack-scala v94 heroku-buildpack-play v26 heroku-buildpack-php v223 heroku-buildpack-go v166 heroku-buildpack-nginx v16 buildpack-null v3 -----> dokku version: dokku version 0.28.1 -----> plugn version: plugn: 0.12.0build+3a27594 -----> dokku plugins: 00_dokku-standard 0.28.1 enabled dokku core standard plugin 20_events 0.28.1 enabled dokku core events logging plugin app-json 0.28.1 enabled dokku core app-json plugin apps 0.28.1 enabled dokku core apps plugin builder 0.28.1 enabled dokku core builder plugin builder-dockerfile 0.28.1 enabled dokku core builder-dockerfile plugin builder-herokuish 0.28.1 enabled dokku core builder-herokuish plugin builder-lambda 0.27.0 enabled dokku core builder-lambda plugin builder-null 0.28.1 enabled dokku core builder-null plugin builder-pack 0.28.1 enabled dokku core builder-pack plugin buildpacks 0.28.1 enabled dokku core buildpacks plugin caddy-vhosts 0.28.1 enabled dokku core caddy-vhosts plugin certs 0.28.1 enabled dokku core certificate management plugin checks 0.28.1 enabled dokku core checks plugin common 0.28.1 enabled dokku core common plugin config 0.28.1 enabled dokku core config plugin cron 0.28.1 enabled dokku core cron plugin docker-options 0.28.1 enabled dokku core docker-options plugin domains 0.28.1 enabled dokku core domains plugin enter 0.28.1 enabled dokku core enter plugin git 0.28.1 enabled dokku core git plugin letsencrypt 0.18.1 enabled Automated installation of let's encrypt TLS certificates logs 0.28.1 enabled dokku core logs plugin mongo 1.21.0 enabled dokku mongo service plugin network 0.28.1 enabled dokku core network plugin nginx-vhosts 0.28.1 enabled dokku core nginx-vhosts plugin plugin 0.28.1 enabled dokku core plugin plugin proxy 0.28.1 enabled dokku core proxy plugin ps 0.28.1 enabled dokku core ps plugin redis 1.24.0 enabled dokku redis service plugin registry 0.28.1 enabled dokku core registry plugin repo 0.28.1 enabled dokku core repo plugin resource 0.28.1 enabled dokku core resource plugin run 0.28.1 enabled dokku core run plugin scheduler 0.28.1 enabled dokku core scheduler plugin scheduler-docker-local 0.28.1 enabled dokku core scheduler-docker-local plugin scheduler-null 0.28.1 enabled dokku core scheduler-null plugin shell 0.28.1 enabled dokku core shell plugin ssh-keys 0.28.1 enabled dokku core ssh-keys plugin storage 0.28.1 enabled dokku core storage plugin trace 0.28.1 enabled dokku core trace plugin traefik-vhosts 0.28.1 enabled dokku core traefik-vhosts plugin =====> api app-json information App json computed selected: app.json App json global selected: app.json App json selected: =====> api app information App created at: 1668337727 App deploy source: App deploy source metadata: App dir: /home/dokku/api App locked: false =====> api builder information Builder build dir: Builder computed build dir: Builder computed selected: Builder global build dir: Builder global selected: Builder selected: =====> api builder-dockerfile information Builder dockerfile computed dockerfile path: Dockerfile Builder dockerfile global dockerfile path: Dockerfile Builder dockerfile dockerfile path: =====> api builder-lambda information Builder lambda computed lambdayml path: lambda.yml Builder lambda global lambdayml path: lambda.yml Builder lambda lambdayml path: =====> api builder-pack information Builder pack computed projecttoml path: project.toml Builder pack global projecttoml path: project.toml Builder pack projecttoml path: =====> api buildpacks information Buildpacks computed stack: gliderlabs/herokuish:latest-20 Buildpacks global stack: Buildpacks list: Buildpacks stack: =====> api ssl information Ssl dir: /home/dokku/api/tls Ssl enabled: true Ssl hostnames: api.codeisscience.com Ssl expires at: Feb 10 08:27:28 2023 GMT Ssl issuer: C = US, O = Let's Encrypt, CN = R3 Ssl starts at: Nov 12 08:27:29 2022 GMT Ssl subject: subject=CN = api.codeisscience.com Ssl verified: self signed =====> api checks information Checks disabled list: none Checks skipped list: none =====> api cron information Cron task count: 0 =====> api docker options information Docker options build: --link dokku.mongo.maindb:dokku-mongo-maindb --link dokku.redis.memorydb:dokku-redis-memorydb Docker options deploy: --link dokku.mongo.maindb:dokku-mongo-maindb --link dokku.redis.memorydb:dokku-redis-memorydb --restart=on-failure:10 Docker options run: --link dokku.mongo.maindb:dokku-mongo-maindb --link dokku.redis.memorydb:dokku-redis-memorydb =====> api domains information Domains app enabled: true Domains app vhosts: api.codeisscience.com Domains global enabled: true Domains global vhosts: codeisscience.com =====> api git information Git deploy branch: master Git global deploy branch: master Git keep git dir: false Git rev env var: GIT_REV Git sha: b3365a8 Git last updated at: 1668251622 =====> api letsencrypt information Letsencrypt active: true Letsencrypt autorenew: false Letsencrypt email: codeisscience@gmail.com Letsencrypt expiration: 1676017648 =====> api logs information Logs computed max size: 10m Logs global max size: 10m Logs global vector sink: Logs max size: Logs vector sink: =====> api network information Network attach post create: Network attach post deploy: Network bind all interfaces: false Network computed attach post create: Network computed attach post deploy: Network computed bind all interfaces: false Network computed initial network: Network computed tld: Network global attach post create: Network global attach post deploy: Network global bind all interfaces: false Network global initial network: Network global tld: Network initial network: Network static web listener: Network tld: Network web listeners: =====> api nginx information Nginx access log format: Nginx access log path: /var/log/nginx/api-access.log Nginx bind address ipv4: Nginx bind address ipv6: :: Nginx client max body size: Nginx disable custom config: false Nginx error log path: /var/log/nginx/api-error.log Nginx global hsts: true Nginx computed hsts: true Nginx hsts: Nginx hsts include subdomains: true Nginx hsts max age: 15724800 Nginx hsts preload: false Nginx proxy buffer size: 4096 Nginx proxy buffering: on Nginx proxy buffers: 8 4096 Nginx proxy busy buffers size: 8192 Nginx proxy read timeout: 60s Nginx last visited at: 1668245243 Nginx x forwarded for value: $remote_addr Nginx x forwarded port value: $server_port Nginx x forwarded proto value: $scheme Nginx x forwarded ssl: =====> api proxy information Proxy enabled: true Proxy port map: http:80:5000 https:443:5000 Proxy type: nginx =====> api ps information Deployed: false Processes: 0 Ps can scale: true Ps computed procfile path: Procfile Ps global procfile path: Procfile Ps procfile path: Ps restart policy: on-failure:10 Restore: true Running: false =====> api registry information Registry computed image repo: dokku/api Registry computed push on release: false Registry computed server: Registry global push on release: Registry global server: Registry image repo: Registry push on release: Registry server: Registry tag version: =====> api resource information =====> api scheduler information Scheduler computed selected: docker-local Scheduler global selected: docker-local Scheduler selected: =====> api scheduler-docker-local information Scheduler docker local disable chown: Scheduler docker local init process: true Scheduler docker local parallel schedule count: =====> api storage information Storage build mounts: Storage deploy mounts: Storage run mounts: ```
josegonzalez commented 1 year ago

The only way to do this would be to commit the file to the repo. The remote dokku server only has what is pushed as it's context.

As an alternative, you can build the image in Github Actions, push it to a registry, then deploy that image.