https://github.com/spacetab-io/docker-images-golang
base docker images for golang projects pipelines
https://github.com/spacetab-io/docker-images-golang
building docker docker-image docker-images-golang dockerfile go golang lint linter testing testing-golang
Last synced: about 1 month ago
JSON representation
base docker images for golang projects pipelines
- Host: GitHub
- URL: https://github.com/spacetab-io/docker-images-golang
- Owner: spacetab-io
- License: mit
- Created: 2020-04-25T08:40:24.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-02T10:52:26.000Z (over 2 years ago)
- Last Synced: 2025-02-14T22:13:54.125Z (3 months ago)
- Topics: building, docker, docker-image, docker-images-golang, dockerfile, go, golang, lint, linter, testing, testing-golang
- Language: Shell
- Size: 67.4 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
docker-images-golang
-------------------Images for docker containers:
* [Lint environment](linter) container is for lint golang app source code.
Uses [golangci-lint](https://github.com/golangci/golangci-lint) to lint code
with [custom config](https://github.com/spacetab-io/linter-go).
* [Test environment](test) container is for testing golang app. Has all things to test golang sources with `go test`.
* [Build environment](build) container is for building golang app. Has all things to build golang app with go modules.
* [Base environment](base) container is for running golang app. Has all things to run binaries in formalized application
structure. Exposes `8080` port and run service command: `/app/bin/service`. Only thing you must do is copy binaries,
Makefile (if needed), migrations (if needed) and application default configuration.## Building image
Simply run a `make` command
make build-base-image # to build base image
make build-build-image # to build building image
make build-linter-image # to build linterr image
make build-test-image # to build test image
make build-all # to build all images## Pushing image
Simply run a `make` command
make push-base-image # to push base image
make push-build-image # to push building image
make push-linter-image # to push linterr image
make push-test-image # to push test image
make push-all # to push all images## Images usage
Common usage application Dockerfile:
```dockerfile
FROM spacetabio/docker-lint-golang:1.12-latest as lint-envCOPY . /app
RUN make lint# ----
FROM spacetabio/docker-test-golang:1.12-latest as test-env
COPY . /app
RUN make test# ----
FROM spacetabio/docker-build-golang:1.12-latest as build-env
COPY . /app
RUN make all# ----
FROM spacetabio/docker-base-golang:1.12-latest
COPY --from=build-env /app/bin/* /app/bin/
COPY --from=build-env /app/Makefile /app/
COPY --from=build-env /app/migrations/* /app/migrations/
COPY --from=build-env /app/configuration/defaults /app/configuration/defaults
```If private packages are used, build it with Dockerfile below and command:
`docker build -t : --build-arg TOKEN="$(cat ~/.ci-token)" --build-arg PRIVATE_REPO="private.repo.url" .````dockerfile
FROM spacetabio/docker-test-golang:1.12-latest as test-envARG TOKEN
ARG PRIVATE_REPO
RUN git config --global url."https://ci-token:${TOKEN}@${PRIVATE_REPO}/".insteadOf 'https://${PRIVATE_REPO}/'COPY . /app
RUN make test
```## LICENCE
MIT License
Copyright (c) 2022 Spacetab.io
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "
Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.