Skip to content

Commit 59d7468

Browse files
committed
[CI/CD] Add github workflows for deploying server image
1 parent 45a5889 commit 59d7468

15 files changed

Lines changed: 146 additions & 42 deletions

File tree

.env

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/workflows/master.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Master
2+
on:
3+
push:
4+
branches:
5+
- master
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Go
16+
uses: actions/setup-go@v5
17+
with:
18+
go-version-file: ./go.mod
19+
20+
- name: Install dependencies
21+
run: go mod tidy
22+
23+
- name: Set up Docker Compose
24+
uses: docker/setup-buildx-action@v3
25+
26+
- name: Build and Run Server
27+
run: |
28+
docker compose up --build --force-recreate --remove-orphans -d server

.github/workflows/pr.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: PR
2+
on:
3+
pull_request:
4+
branches:
5+
- "*"
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Go
16+
uses: actions/setup-go@v5
17+
with:
18+
go-version-file: ./go.mod
19+
20+
- name: Install dependencies
21+
run: go mod tidy
22+
23+
- name: Run tests
24+
run: go test ./...
25+
26+
- name: Lint code
27+
uses: golangci/golangci-lint-action@v6
28+
with:
29+
version: latest

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release
2+
on:
3+
release:
4+
types: [published]
5+
6+
jobs:
7+
release:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Set up Docker Compose
15+
uses: docker/setup-buildx-action@v3
16+
17+
- name: Build And Tag Image
18+
run: |
19+
docker compose up --build --force-recreate --remove-orphans -d server
20+
docker tag passeriformub/nukeship:latest passeriformub/nukeship:${{ github.ref_name }}
21+
22+
- name: Publish Docker Image
23+
uses: docker/login-action@v3
24+
with:
25+
username: ${{ secrets.DOCKER_USERNAME }}
26+
password: ${{ secrets.DOCKER_PASSWORD }}
27+
28+
- name: Push Docker Image to Docker Hub
29+
run: |
30+
docker push passeriformub/nukeship:${{ github.ref_name }}
31+
docker push passeriformub/nukeship:latest

.vscode/launch.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
"cli"
2626
],
2727
"env": {
28-
"GOPATH": "${workspaceFolder}"
28+
"GOPATH": "${workspaceFolder}",
29+
"SERVER_HOST": "https://nukeship.passeriform.com",
30+
"SERVER_PORT": "50051"
2931
},
3032
"args": [
3133
"createRoom"

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"assetdir",
77
"Bhardwaj",
88
"bidichk",
9+
"buildx",
910
"bytebufferpool",
1011
"caarlos",
1112
"containedctx",
@@ -33,8 +34,10 @@
3334
"gocyclo",
3435
"godbus",
3536
"godoc",
37+
"godotenv",
3638
"godox",
3739
"gofumpt",
40+
"golangci",
3841
"gommon",
3942
"gosod",
4043
"govet",
@@ -62,6 +65,7 @@
6265
"Orbitron",
6366
"outputfilename",
6467
"passeriform",
68+
"passeriformub",
6569
"perfsprint",
6670
"permonitor",
6771
"permonitorv2",
@@ -126,6 +130,10 @@
126130
"editor.defaultFormatter": "golang.go",
127131
"editor.insertSpaces": false
128132
},
133+
"[yaml]": {
134+
"editor.defaultFormatter": "redhat.vscode-yaml",
135+
"editor.tabSize": 2
136+
},
129137
"prettier.tabWidth": 4,
130138
"editor.detectIndentation": false,
131139
"editor.insertSpaces": true,

.vscode/tasks.json

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@
22
// See https://go.microsoft.com/fwlink/?LinkId=733558
33
// for the documentation about the tasks.json format
44
"version": "2.0.0",
5-
"options": {
6-
"env": {
7-
"ENVIRONMENT": "PRODUCTION",
8-
"PORT": "50051",
9-
"SERVER_PORT": "50051",
10-
"HOST": "127.0.0.1",
11-
"SERVER_HOST": "127.0.0.1",
12-
}
13-
},
145
"tasks": [
156
{
167
"label": "[Protobuf] Refresh",
@@ -33,7 +24,11 @@
3324
"label": "[App] Build Client",
3425
"type": "shell",
3526
"options": {
36-
"cwd": "${workspaceFolder}/pkg/client"
27+
"cwd": "${workspaceFolder}/pkg/client",
28+
"env": {
29+
"SERVER_HOST": "https://nukeship.passeriform.com",
30+
"SERVER_PORT": "50051"
31+
}
3732
},
3833
"command": "wails",
3934
"args": [
@@ -56,7 +51,11 @@
5651
"dev"
5752
],
5853
"options": {
59-
"cwd": "${workspaceFolder}/pkg/client"
54+
"cwd": "${workspaceFolder}/pkg/client",
55+
"env": {
56+
"SERVER_HOST": "https://nukeship.passeriform.com",
57+
"SERVER_PORT": "50051"
58+
}
6059
},
6160
"dependsOrder": "sequence",
6261
"dependsOn": [
@@ -65,7 +64,7 @@
6564
"problemMatcher": [],
6665
"runOptions": {
6766
"instanceLimit": 2
68-
}
67+
},
6968
},
7069
{
7170
"label": "[Server] [Local] Run Server",
@@ -99,8 +98,7 @@
9998
},
10099
"files": [
101100
"docker-compose.yml"
102-
],
103-
"envFile": ".env"
101+
]
104102
},
105103
"options": {
106104
"cwd": "${workspaceFolder}"
@@ -121,7 +119,11 @@
121119
"createRoom"
122120
],
123121
"options": {
124-
"cwd": "${workspaceFolder}/pkg/client"
122+
"cwd": "${workspaceFolder}/pkg/client",
123+
"env": {
124+
"SERVER_HOST": "https://nukeship.passeriform.com",
125+
"SERVER_PORT": "50051"
126+
}
125127
}
126128
},
127129
{
@@ -140,7 +142,11 @@
140142
"-code=${input:roomCode}"
141143
],
142144
"options": {
143-
"cwd": "${workspaceFolder}/pkg/client"
145+
"cwd": "${workspaceFolder}/pkg/client",
146+
"env": {
147+
"SERVER_HOST": "https://nukeship.passeriform.com",
148+
"SERVER_PORT": "50051"
149+
}
144150
}
145151
}
146152
],

Dockerfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
ARG ENVIRONMENT=PRODUCTION
2+
ARG PORT=50051
3+
14
# --- Server Builder --- #
25

36
# TODO: Add godoc server hosting
@@ -32,9 +35,12 @@ RUN go build -ldflags "-extldflags '-static'" -o /artifact/server ./pkg/server/.
3235
FROM scratch
3336
LABEL maintainer="Utkarsh Bhardwaj (Passeriform) <bhardwajutkarsh.ub@gmail.com>"
3437

38+
ARG ENVIRONMENT
39+
ARG PORT
40+
3541
WORKDIR /app
3642
COPY --from=builder /artifact/server ./
37-
ENV ENVIRONMENT PRODUCTION
38-
ENV PORT 8080
39-
EXPOSE 8080
43+
ENV ENVIRONMENT ${ENVIRONMENT}
44+
ENV PORT ${PORT}
45+
EXPOSE ${PORT}
4046
CMD ["./server"]

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
![Issues](https://img.shields.io/github/issues/Passeriform/NukeShip)
55
![Stars](https://img.shields.io/github/stars/Passeriform/NukeShip)
66
![Forks](https://img.shields.io/github/forks/Passeriform/NukeShip)
7+
[![Deploy to Koyeb](https://www.koyeb.com/static/images/deploy/button.svg)](https://app.koyeb.com/deploy?name=nukeship&repository=Passeriform%2FNukeShip&branch=master&instance_type=free)
78

89
<div align="center">
910
<img src="./pkg/client/frontend/src/assets/radioactive.svg" alt="Radioactive Icon" width="150"/>

docker-compose.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ services:
22
server:
33
build:
44
context: .
5-
dockerfile: server.Dockerfile
6-
environment:
7-
ENVIRONMENT: ${ENVIRONMENT:-PRODUCTION}
5+
dockerfile: Dockerfile
6+
args:
7+
ENVIRONMENT: ${ENVIRONMENT:-PRODUCTION}
8+
PORT: ${PORT:-50051}
9+
image: passeriformub/nukeship:latest
810
ports:
9-
- ${PORT:-80}:8080
11+
- 50051:${PORT:-50051}

0 commit comments

Comments
 (0)