GithubHelp home page GithubHelp logo

olliefr / docker-gs-ping Goto Github PK

View Code? Open in Web Editor NEW
67.0 4.0 274.0 37 KB

[ARCHIVED] A simple Go server example for Docker's "Getting Started with Docker and Go".

License: Apache License 2.0

Dockerfile 31.97% Go 68.03%
docker go golang dockertest example example-project

docker-gs-ping's Introduction

Caution

This repo is out-of-date and archived. The development continues at docker/docker-gs-ping.

docker-gs-ping

A simple Go server/microservice example for Docker's Go Language Guide.

Notable features:

  • Includes a multi-stage Dockerfile.
  • Has a CI pipeline using GitHub Actions to run tests.
  • Has a CD pipeline using GitHub Actions to publish to Docker Hub.

Want moar?!

There is a more advanced example in olliefr/docker-gs-ping-roach using CockroachDB.

Contributing

This was written for an introduction section of the Docker tutorial and as such it favours brevity and pedagogical clarity over robustness.

Thus, feedback is welcome, but please no nits or pedantry. Ain't nobody got time for that ๐Ÿ™ƒ

License

Apache-2.0 License

docker-gs-ping's People

Contributors

dodsonmg avatar olliefr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

docker-gs-ping's Issues

CI/CD Tutorial: Push to Docker fails if GitHub and Docker usernames are different

tags: ${{ github.repository }}:latest

I think the above line requires modification if the user's GitHub and Docker Hub usernames don't match. It might be worth noting in the CI/CD portion of the tutorial.

I'd be happy to submit a PR, but I think my own solution is a bit of a hack and probably not what you want either here or in the tutorial. I'm sure there's a smarter way to use secrets.DOCKER_HUB_USERNAME, but I can't figure it out.

I'm also not sure whether the PR should start with the code repo or the tutorial repo, so I figured I'd start with a discussion here first.

More details below.


First, this is such a useful tutorial. The CI/CD portion particularly has been tremendously helpful. I'm new to Docker (hence going through tutorials) and had no real intuition for how people were using it for CD in particular. The tutorial's style and simple examples have brought me a long way. Thank you.

Now to the issue:

The release workflow was failing during the Build and push Docker image step with the following:

#12 pushing dodsonmg/docker-gs-ping:latest with docker
#12 pushing layer bb0e01146d01
...
#12 pushing layer 72e830a4dff5 0.3s done
#12 ERROR: denied: requested access to the resource is denied
------
 > pushing dodsonmg/docker-gs-ping:latest with docker:
------
error: denied: requested access to the resource is denied
Error: buildx failed with: error: denied: requested access to the resource is denied

For no useful reason, I had different usernames for GitHub and Docker Hub. ${{ github.repository }} resolves to dodsonmg/docker-gs-ping (as you can see above...); however, since dodsonmg wasn't my Docker Hub username, the push was failing, despite the fact that the Login to Docker Hub step was passing.

I modified the line to:
tags: md403/docker-gs-ping:latest (md403 being my Docker Hub username) and it worked fine.

Thankfully, my GitHub username is also available on Docker Hub, so I changed it and the repo code works as expected without modifications.

Encountered Docker Error: "When using COPY with more than one source file, the destination must be a directory and end with a /""

OS & Docker version
My docker version: 20.10.7, build f0df35096d
OS: arch-linux

Reproducing the Error:
Good day olliefr, I encountered an error when going through the golang docker tutorial.

The following commands were run:
git clone https://github.com/olliefr/docker-gs-ping
cd docker-gs-ping
docker build --tag docker-gs-ping .

The Error
When using COPY with more than one source file, the destination must be a directory and end with a /

The Solution
By changing line 12 in the Dockerfile from:
COPY *.go .
to
COPY *.go ./

I am not sure if this solution will cause other issues. I doubt it but I can investigate and make a pull request if this error is significant enough.

I am also curious if other people encountered this error or if it is only on my machine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.