Skip to content

Commit

Permalink
Initial container builds
Browse files Browse the repository at this point in the history
  • Loading branch information
timburks committed Jul 11, 2024
1 parent b4b9c7a commit 2d93552
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 14 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Publish docker images

on:
schedule:
- cron: '0 0 * * *' # each 12:00 UTC
push:
branches: [ main ]
tags: [ 'v*.*.*' ] # semver release
pull_request:
branches: [ main ]

env:
IMAGE: menus-server

jobs:

build-container:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Log into registry ghcr.io
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=schedule,pattern=nightly
type=raw,latest
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: "."
file: Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
24 changes: 24 additions & 0 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Go

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v3
with:
go-version: 1.22

- name: Build
run: go install -v ./...

- name: Test
run: go test -v ./...
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM golang:1.22.5 as builder
WORKDIR /app
COPY . ./
RUN CGO_ENABLED=0 GOOS=linux go build -v -o menus-server ./cmd/menus-server

FROM alpine:3
RUN apk add --no-cache ca-certificates
COPY --from=builder /app/menus-server /usr/local/bin/menus-server
COPY --from=builder /app/data /data
CMD ["/usr/local/bin/menus-server"]
14 changes: 0 additions & 14 deletions cmd/menus-server/main.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
// Copyright 2023 Google LLC. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
Expand Down
1 change: 1 addition & 0 deletions data/TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO

0 comments on commit 2d93552

Please sign in to comment.