docker test
All checks were successful
Build docker container / Build image (push) Successful in 2m2s
All checks were successful
Build docker container / Build image (push) Successful in 2m2s
This commit is contained in:
parent
f7d8233a10
commit
1d1f9b0fe7
30
.gitea/workflows/release.yaml
Normal file
30
.gitea/workflows/release.yaml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
name: Build docker container
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build image
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: ghcr.io/catthehacker/ubuntu:act-latest
|
||||||
|
env:
|
||||||
|
IMAGE_NAME: ip-svc
|
||||||
|
REGISTRY: git.mzsl.nl
|
||||||
|
REPO_OWNER: mans
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: git.mzsl.nl
|
||||||
|
username: ${{ secrets.LOGIN_USER }}
|
||||||
|
password: ${{ secrets.LOGIN_PASS }}
|
||||||
|
- name: Build and push
|
||||||
|
run: |
|
||||||
|
TODAY=$(date +'%Y-%m-%d')
|
||||||
|
docker build -t ${REGISTRY}/${REPO_OWNER}/${IMAGE_NAME}:${TODAY} -t ${REGISTRY}/${REPO_OWNER}/${IMAGE_NAME}:latest .
|
||||||
|
docker push ${REGISTRY}/${REPO_OWNER}/${IMAGE_NAME}:${TODAY}
|
||||||
|
docker push ${REGISTRY}/${REPO_OWNER}/${IMAGE_NAME}:latest
|
33
Dockerfile
Normal file
33
Dockerfile
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# Stage 1: Build the Go application
|
||||||
|
FROM golang:1.22 AS builder
|
||||||
|
|
||||||
|
# Set the Current Working Directory inside the container
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy go mod and sum files
|
||||||
|
COPY go.mod ./
|
||||||
|
|
||||||
|
# Download all dependencies. Dependencies will be cached if the go.mod and go.sum files are not changed
|
||||||
|
RUN go mod download
|
||||||
|
|
||||||
|
# Copy the source code into the container
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Build the Go app
|
||||||
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o server .
|
||||||
|
|
||||||
|
# Stage 2: Create a small image with just the compiled binary
|
||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
# Set the Current Working Directory inside the container
|
||||||
|
WORKDIR /root/
|
||||||
|
|
||||||
|
# Copy the pre-built binary file from the previous stage
|
||||||
|
COPY --from=builder /app/server .
|
||||||
|
|
||||||
|
# Expose the port that the application will run on
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
# Command to run the executable
|
||||||
|
CMD ["./server"]
|
||||||
|
|
45
compose.yml
Normal file
45
compose.yml
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
services:
|
||||||
|
|
||||||
|
traefik:
|
||||||
|
image: "traefik:v3.0"
|
||||||
|
container_name: "traefik"
|
||||||
|
command:
|
||||||
|
#- "--log.level=DEBUG"
|
||||||
|
- "--api.insecure=true"
|
||||||
|
- "--providers.docker=true"
|
||||||
|
- "--providers.docker.exposedbydefault=false"
|
||||||
|
- "--entryPoints.web.address=:80"
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
- "8090:8080"
|
||||||
|
volumes:
|
||||||
|
- "/var/run/docker.sock:/var/run/docker.sock:ro"
|
||||||
|
networks:
|
||||||
|
- test
|
||||||
|
|
||||||
|
whoami:
|
||||||
|
image: "traefik/whoami"
|
||||||
|
container_name: "simple-service"
|
||||||
|
labels:
|
||||||
|
- "traefik.enable=true"
|
||||||
|
- "traefik.http.routers.whoami.rule=Path(`/`)"
|
||||||
|
- "traefik.http.routers.whoami.entrypoints=web"
|
||||||
|
networks:
|
||||||
|
- test
|
||||||
|
|
||||||
|
ip-svc:
|
||||||
|
build: .
|
||||||
|
container_name: "ip-svc"
|
||||||
|
labels:
|
||||||
|
- "traefik.enable=true"
|
||||||
|
- "traefik.http.routers.ip-svc.rule=Path(`/`) || Path(`/api`)"
|
||||||
|
- "traefik.http.routers.ip-svc.entrypoints=web"
|
||||||
|
networks:
|
||||||
|
- test
|
||||||
|
|
||||||
|
networks:
|
||||||
|
test:
|
||||||
|
enable_ipv6: true
|
||||||
|
driver: bridge
|
||||||
|
default:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user