Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multistage #54

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
02d4d9e
set port 9091
manuh-L Feb 9, 2023
264d0a0
add EL line
manuh-L Feb 9, 2023
8942531
containerize, add dockerfile
manuh-L Feb 9, 2023
7c80c60
distros
manuh-L Feb 9, 2023
291ea79
using multi stage
manuh-L Feb 19, 2023
d6cd17d
Change image to nhiuana/ubuntu-libsqlite3
manuh-L Feb 19, 2023
28de3ac
add k8s manifest
manuh-L Apr 9, 2023
a70fec5
init cicd with docker
manuh-L May 15, 2023
a19c22d
fix docker build syntax
manuh-L May 15, 2023
d69a7f8
more stages
manuh-L May 15, 2023
eb0770f
fb dockerfile
manuh-L May 15, 2023
1e5e600
add path entrypoint
manuh-L May 15, 2023
aa6c83b
v1.1 make image
manuh-L May 15, 2023
515176c
test packer
manuh-L May 15, 2023
4cea425
outro runner
manuh-L May 15, 2023
60e4d2b
comment before script
manuh-L May 15, 2023
7a9c0c9
needs
manuh-L May 15, 2023
8d0f6f2
kas
manuh-L May 23, 2023
2aed459
k8s agent test
manuh-L May 23, 2023
1dcfa2a
fix typo
manuh-L May 23, 2023
955661a
fix typo
manuh-L May 23, 2023
0010ebc
fix tag error
manuh-L May 23, 2023
c98baeb
context
manuh-L May 23, 2023
1016bce
context
manuh-L May 23, 2023
47b3e4b
use local shell
manuh-L May 23, 2023
c5f8d1b
use local shell
manuh-L May 23, 2023
6039470
project path
manuh-L May 23, 2023
02949e9
project path
manuh-L May 23, 2023
22a178b
project path
manuh-L May 23, 2023
09f733b
agent path
manuh-L May 23, 2023
d4fb94c
agent path config
manuh-L May 23, 2023
0868ca4
agent path conf
manuh-L May 23, 2023
d4d2d57
tes kct
manuh-L May 23, 2023
928fb7f
k8s only
manuh-L May 23, 2023
1ba277d
k8s only
manuh-L May 23, 2023
59de3ec
k8s docker
manuh-L May 23, 2023
808db2f
k8s docker exec
manuh-L May 23, 2023
96000b6
new agent
manuh-L May 23, 2023
3612b90
lb service
manuh-L Sep 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
stages:
- build
- test
- deploy
- review
- dast
- staging
- canary
- production
- performance
- cleanup
#sast:
# stage: test
#include:
#- template: Auto-DevOps.gitlab-ci.yml


#default:
# before_script:
# - docker login -u $HARBOR_USERNAME -p $HARBOR_PASSWORD $HARBOR_HOST


#compile:
# stage: build
# tags:
# - docker-02
# image:
# name: harbor.lab.com/library/make:v1.1
# entrypoint:
# - '/usr/bin/env'
# - 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin'
# script:
# - make all
# artifacts:
# paths:
# - bin/facebooc
# untracked: true
# when: on_success
# expire_in: "7 days"



#image build:
# stage: build
# tags:
# - lab
# script:
# - pwd; ls
# - docker image build -t "${HARBOR_HOST}/${HARBOR_PROJECT}/fb:${CI_COMMIT_TAG}" -f fb.Dockerfile .
# dependencies:
# - compile
# needs:
# - job: compile
# artifacts: true


#upload to registry:
# stage: test
# tags:
# - lab
# script:
# - docker login -u $HARBOR_USERNAME -p $HARBOR_PASSWORD $HARBOR_HOST
# - docker push "${HARBOR_HOST}/${HARBOR_PROJECT}"/fb:33 #${CI_COMMIT_TAG}"


deploy:
tags:
- docker-02
image:
name: bitnami/kubectl:latest
entrypoint: ['']
script:
- echo $KUBECONFIG
- kubectl config get-contexts
# - kubectl config use-context kind-demo
- kubectl config use-context manuh/facebooc:joker
- cat $KUBECONFIG
- kubectl config view
- kubectl get namespaces
- kubectl get no


#build-image:
# stage: build
# script:
# - echo "$HARBOR_PROJECT $HARBOR_URL $HARBOR_HOST $HARBOR_PASSWORD"
## - docker build -t "${HARBOR_HOST}/${HARBOR_PROJECT}/fb:{$CI_COMMIT_TAG}" .
## - mkdir -p .docker; echo "{\"auths\":{\"${HARBOR_HOST}\":{\"auth\":\"$(echo -n ${HARBOR_USERNAME}:${HARBOR_PASSWORD} | base64)\"}}}" > .docker/config.json
## - docker tag hello-world:latest harbor.lab.com/library/hello_cicd:test
## - docker push "${HARBOR_HOST}/${HARBOR_PROJECT}/hello_cicd:test"
# - docker image build -t "${HARBOR_HOST}/${HARBOR_PROJECT}/fb:${CI_COMMIT_TAG}" .
# - docker push "${HARBOR_HOST}/${HARBOR_PROJECT}/fb:${CI_COMMIT_TAG}"

#run:
# stage: staging
# script:
# - echo "${CI_COMMIT_TAG}"
# - docker image ls
# - docker run -itd -P --name fb harbor.lab.com/library/fb:${CI_COMMIT_TAG}
3 changes: 3 additions & 0 deletions .gitlab/agents/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ci_access:
projects:
- id: manuh/facebooc
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM rockylinux:9.1 AS BUILD

WORKDIR /opt/facebooc

COPY . .

RUN yum install -yq gcc gcc-c++ glibc-devel make sqlite-devel sqlite && \
make all

FROM nhiuana/ubuntu-libsqlite3:latest AS RUN
WORKDIR /opt/facebooc
COPY --from=BUILD /opt/facebooc/bin ./bin/
COPY --from=BUILD /opt/facebooc/static ./static/
COPY --from=BUILD /opt/facebooc/templates ./templates/
EXPOSE 9091
CMD bin/facebooc
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ Proof-of-concept Facebook clone in C.
The only dependency is SQLite3.

# Prerequisites
Install SQLite development package:
Install SQLite development package: </br>
#Debian
```bash
sudo apt-get install libsqlite3-dev
```
#EL
```bash
sudo dnf install sqlite-devel sqlite
```


# Build and Run
```bash
Expand Down
7 changes: 7 additions & 0 deletions fb.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM nhiuana/ubuntu-libsqlite3:latest
WORKDIR /opt/facebooc
COPY ./bin ./bin/
COPY ./static ./static/
COPY ./templates ./templates/
EXPOSE 9091
CMD bin/facebooc
17 changes: 17 additions & 0 deletions k8s/fb-svc-lb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: fb
name: fb
spec:
ports:
- name: "noventa"
port: 9091
protocol: TCP
targetPort: 9091
selector:
app: fb
type: LoadBalancer
status:
loadBalancer: {}
19 changes: 19 additions & 0 deletions k8s/fb-svc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
app: fb
name: fb
spec:
ports:
- name: "9091"
nodePort: 30000
port: 9091
protocol: TCP
targetPort: 9091
selector:
app: fb
type: NodePort
status:
loadBalancer: {}
24 changes: 24 additions & 0 deletions k8s/fb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: fb
name: fb
spec:
replicas: 1
selector:
matchLabels:
app: fb
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: fb
spec:
containers:
- image: nhiuana/fb:v5
name: fb
resources: {}
status: {}
6 changes: 3 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ int main(int argc, char *argv[])

initDB();

uint16_t server_port = 8080;
uint16_t server_port = 9091;
if (argc > 1) {
if (sscanf(argv[1], "%hu", &server_port) == 0) {
fprintf(stderr,
"error: invalid command line argument, using default port "
"8080.\n");
server_port = 8080;
"9091.\n");
server_port = 9091;
}
}
Server *server = serverNew(server_port);
Expand Down
5 changes: 4 additions & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ <h3>Prerequisites</h3>
Install SQLite development package:
</p>
<div class="codeblock">
sudo apt-get install libsqlite3-dev
sudo apt-get install libsqlite3-dev </br>
#EL</br>
sudo dnf install sqlite-devel sqlite </br>

</div>
<h3>Build and Run</h3>
<div class="codeblock">
Expand Down