Skip to content

Commit

Permalink
add ci
Browse files Browse the repository at this point in the history
  • Loading branch information
junaidrahim committed Jan 2, 2022
1 parent 0482ff9 commit 0bb9d26
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 2 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
name: Create and publish a Docker image

on:
release:
types: [published]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: ./server
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
25 changes: 25 additions & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# parent image
FROM golang:1.15.6-alpine3.12

# workspace directory
WORKDIR /divert

# copy `go.mod` and `go.sum`
ADD ./go.mod ./go.sum ./

# install dependencies
RUN go mod download

RUN apk add build-base

# copy source code
COPY . .

# build executable
RUN go build

# expose ports
EXPOSE 3000

# set entrypoint
ENTRYPOINT [ "./divert" ]
Binary file removed server/divert
Binary file not shown.
4 changes: 4 additions & 0 deletions server/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: 3.8
services:
divert:
image:
4 changes: 2 additions & 2 deletions server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"log"
"net/http"
"os"
// "os"

"github.com/DSC-KIIT/divert/router"
)
Expand All @@ -18,7 +18,7 @@ func main() {
// os.Setenv("AUTH_COLLECTION_NAME", "authinfo")
// os.Setenv("JWT_SIGNING_KEY", "junaidrahim")

port := os.Getenv("PORT")
port := "3000"

r := router.Router()
fmt.Println("DSCKIIT Divert Backend Service - Starting server on the port " + port)
Expand Down

0 comments on commit 0bb9d26

Please sign in to comment.