denoland / deno_docker

Latest dockerfiles and images for Deno - alpine, centos, debian, ubuntu
https://hub.docker.com/r/denoland/deno
MIT License
889 stars 101 forks source link

Use Docker tags to add version control #26

Closed Minigugus closed 4 years ago

Minigugus commented 4 years ago

Currently, we have to manually specify the version tag, as even latest is not defined :

$ docker run hayd/deno
docker: Error response from daemon: manifest for hayd/deno:latest not found: manifest unknown: manifest unknown.

Generic labels might be preferable for version control. It's easier to keep software up to date, especially with Deno which is evolving a lot :

$ docker run -p 8080:8080 -v $PWD:/app hayd/deno:alpine --allow-net index.ts

What about the Node docker images format ?

hayd commented 4 years ago

latest isn't defined? Hmm. I was hoping that supporting hayd/alpine-deno would have that "just work" (in hayd/deno latest could be any image...

I guess I am doing something wrong here: https://github.com/hayd/deno-docker/blob/5be5b66f3b4eb365728d9c46671d79e6e80a190e/.github/workflows/publish.yml#L17-L35

Do you think any of options will fix? https://github.com/elgohr/Publish-Docker-Github-Action#tags

Minigugus commented 4 years ago

I don't really know how Docker works with Github Actions, but I think you're right, "tags" seems the way to go (allows multiple tags for the same image). Maybe something like this could help:

    - name: Publish Docker
      uses: elgohr/Publish-Docker-Github-Action@2.7
      with:
-        name: "hayd/${{ matrix.kind }}-deno:${{ steps.get_version.outputs.VERSION }}"
+        name: "hayd/${{ matrix.kind }}-deno"
        username: ${{ secrets.DOCKER_USERNAME }}
        password: ${{ secrets.DOCKER_PASSWORD }}
        dockerfile: ${{ matrix.kind }}.dockerfile
        cache: true
-       tag_names: true
+       tags: "latest,${{ steps.get_version.outputs.VERSION }}"
    - name: Publish Docker Legacy
      if: matrix.kind != 'amazonlinux1'
      uses: elgohr/Publish-Docker-Github-Action@2.7
      with:
-        name: "hayd/deno:${{ matrix.kind }}-${{ steps.get_version.outputs.VERSION }}"
+        name: "hayd/deno"
        username: ${{ secrets.DOCKER_USERNAME }}
        password: ${{ secrets.DOCKER_PASSWORD }}
        dockerfile: ${{ matrix.kind }}.dockerfile
        cache: true
-       tag_names: true
+       tags: "latest,${{ matrix.kind }},${{ matrix.kind }}-${{ steps.get_version.outputs.VERSION }}"

However, I don't know how to tag the right latest image.

hayd commented 4 years ago

Will play with this tonight and push a latest. 🤞 your diff suggestion "just works". Thanks!

hayd commented 4 years ago

Nearly working: https://github.com/hayd/deno-docker/blob/cae47347e325bea12e317129afde8695e0750469/.github/workflows/publish.yml

I had wanted hayd/deno "latest" to be alpine, but for some reason it's used ubuntu so might need to experiment with this some more.

Minigugus commented 4 years ago

Maybe the tag is overritten when images are tagged, so that only the last image remains latest : https://github.com/hayd/deno-docker/blob/cae47347e325bea12e317129afde8695e0750469/.github/workflows/publish.yml#L10 Maybe move the alpine image at the end : ['amazonlinux1', 'centos', 'debian', 'ubuntu', 'alpine'] ?

hayd commented 4 years ago

I think it's parallel and luck of the draw which wins (or maybe Ubuntu is slightly slower to build)!

I could sleep for 60seconds on alpine before building 😆 (hacky...)

Minigugus commented 4 years ago

https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategymax-parallel :smirk:

hayd commented 4 years ago

I'm confident I have a solution that will work: using alpine as a separate build step. It seems like Publish-Docker-Github-Action is unhappy with two steps to the same repo in the same block (it never pushed the 0.37.0 tag to dockerhub that should have been just from alpine).


Related, it's unclear if I should be doing any of these things: https://github.com/dockerimages/docker-deno/commit/364f74be472b8ef750f749e6814f2f6ed0662f57

(this fork/rename is a little weird.)