chore: added docker
910505a3
5 file(s) · +101 −2
| 1 | + | .git |
|
| 2 | + | .gitignore |
|
| 3 | + | .env |
|
| 4 | + | feeds |
|
| 5 | + | Dockerfile |
|
| 6 | + | compose.yaml |
|
| 7 | + | .dockerignore |
|
| 8 | + | README.md |
|
| 9 | + | LICENSE |
|
| 10 | + | .DS_Store |
|
| 11 | + | **/.DS_Store |
| 1 | + | name: Publish Docker image |
|
| 2 | + | ||
| 3 | + | on: |
|
| 4 | + | push: |
|
| 5 | + | branches: [main] |
|
| 6 | + | tags: ["v*"] |
|
| 7 | + | workflow_dispatch: |
|
| 8 | + | ||
| 9 | + | env: |
|
| 10 | + | REGISTRY: ghcr.io |
|
| 11 | + | IMAGE_NAME: ${{ github.repository }} |
|
| 12 | + | ||
| 13 | + | jobs: |
|
| 14 | + | build-and-push: |
|
| 15 | + | runs-on: ubuntu-latest |
|
| 16 | + | permissions: |
|
| 17 | + | contents: read |
|
| 18 | + | packages: write |
|
| 19 | + | steps: |
|
| 20 | + | - name: Checkout |
|
| 21 | + | uses: actions/checkout@v4 |
|
| 22 | + | ||
| 23 | + | - name: Set up Docker Buildx |
|
| 24 | + | uses: docker/setup-buildx-action@v3 |
|
| 25 | + | ||
| 26 | + | - name: Log in to GHCR |
|
| 27 | + | uses: docker/login-action@v3 |
|
| 28 | + | with: |
|
| 29 | + | registry: ${{ env.REGISTRY }} |
|
| 30 | + | username: ${{ github.actor }} |
|
| 31 | + | password: ${{ secrets.GITHUB_TOKEN }} |
|
| 32 | + | ||
| 33 | + | - name: Extract metadata |
|
| 34 | + | id: meta |
|
| 35 | + | uses: docker/metadata-action@v5 |
|
| 36 | + | with: |
|
| 37 | + | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
|
| 38 | + | tags: | |
|
| 39 | + | type=ref,event=branch |
|
| 40 | + | type=semver,pattern={{version}} |
|
| 41 | + | type=semver,pattern={{major}}.{{minor}} |
|
| 42 | + | type=sha |
|
| 43 | + | type=raw,value=latest,enable={{is_default_branch}} |
|
| 44 | + | ||
| 45 | + | - name: Build and push |
|
| 46 | + | uses: docker/build-push-action@v6 |
|
| 47 | + | with: |
|
| 48 | + | context: . |
|
| 49 | + | platforms: linux/amd64,linux/arm64 |
|
| 50 | + | push: true |
|
| 51 | + | tags: ${{ steps.meta.outputs.tags }} |
|
| 52 | + | labels: ${{ steps.meta.outputs.labels }} |
|
| 53 | + | cache-from: type=gha |
|
| 54 | + | cache-to: type=gha,mode=max |
| 1 | + | # syntax=docker/dockerfile:1 |
|
| 2 | + | ||
| 3 | + | # --- build stage --- |
|
| 4 | + | FROM golang:1.25-alpine AS build |
|
| 5 | + | WORKDIR /src |
|
| 6 | + | ||
| 7 | + | # cache deps |
|
| 8 | + | COPY go.mod go.sum ./ |
|
| 9 | + | RUN go mod download |
|
| 10 | + | ||
| 11 | + | # build |
|
| 12 | + | COPY . . |
|
| 13 | + | RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /out/feeds . |
|
| 14 | + | ||
| 15 | + | # --- runtime stage --- |
|
| 16 | + | FROM gcr.io/distroless/static:nonroot |
|
| 17 | + | WORKDIR /app |
|
| 18 | + | COPY --from=build /out/feeds /app/feeds |
|
| 19 | + | ||
| 20 | + | ENV HOST=0.0.0.0 PORT=3000 |
|
| 21 | + | EXPOSE 3000 |
|
| 22 | + | USER nonroot:nonroot |
|
| 23 | + | ENTRYPOINT ["/app/feeds"] |
| 1 | + | services: |
|
| 2 | + | feeds: |
|
| 3 | + | build: . |
|
| 4 | + | image: ghcr.io/stevedylandev/feeds:latest |
|
| 5 | + | ports: |
|
| 6 | + | - "3000:3000" |
|
| 7 | + | environment: |
|
| 8 | + | HOST: 0.0.0.0 |
|
| 9 | + | PORT: 3000 |
|
| 10 | + | BASE_URL: ${BASE_URL:-http://localhost:3000} |
|
| 11 | + | restart: unless-stopped |
| 6 | 6 | <meta name="theme-color" content="#ffffff" /> |
|
| 7 | 7 | <link rel="stylesheet" href="/static/styles.css" /> |
|
| 8 | 8 | <title>Feeds</title> |
|
| 9 | - | <meta name="description" content="Try out RSS feeds" /> |
|
| 9 | + | <meta name="description" content="Experience RSS feeds" /> |
|
| 10 | 10 | <link rel="icon" type="image/x-icon" href="/static/favicon.ico" /> |
|
| 11 | 11 | <link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png" /> |
|
| 12 | 12 | <link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png" /> |
|
| 17 | 17 | <meta property="og:url" content="{{.BaseURL}}" /> |
|
| 18 | 18 | <meta property="og:type" content="website" /> |
|
| 19 | 19 | <meta property="og:title" content="Feeds" /> |
|
| 20 | - | <meta property="og:description" content="Try out RSS feeds" /> |
|
| 20 | + | <meta property="og:description" content="Experience RSS feeds" /> |
|
| 21 | 21 | <meta property="og:image" content="{{.BaseURL}}/static/og.png" /> |
|
| 22 | 22 | </head> |
|
| 23 | 23 | <body> |
|