added nginx config and rewrote Dockerfile and gitlab ci

This commit is contained in:
AHMZA
2021-12-08 22:25:02 +00:00
parent 864a1058d8
commit b9d64b7728
3 changed files with 52 additions and 13 deletions
+11 -7
View File
@@ -1,9 +1,10 @@
image: "gitlab/dind"
stages:
- build
- dockerize
variables:
CONTAINER_IMAGE: registry.gitlab.com/ahmza/blog:latest
Build:
stage: build
image: alpine:latest
@@ -20,8 +21,11 @@ Build:
Dockerize:
stage: dockerize
before_script:
- docker login registry.gitlab.com -u ahmza -p $CI_DOCKER_ACCESS_TOKEN
script:
- docker build -t registry.gitlab.com/ahmza/blog .
- docker push registry.gitlab.com/ahmza/blog
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:latest
+5 -6
View File
@@ -1,6 +1,5 @@
FROM alpine:latest
RUN which curl || ( apk update && apk add curl )
RUN curl -L https://github.com/gohugoio/hugo/releases/download/v0.90.0/hugo_0.90.0_Linux-64bit.tar.gz > hugo.tar.gz
RUN tar -zxf hugo.tar.gz
RUN mv hugo /usr/local/bin/hugo
CMD hugo
FROM nginx:alpine
COPY .build /var/www
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
ENTRYPOINT ["nginx","-g","daemon off;"]
+36
View File
@@ -0,0 +1,36 @@
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format compression '$remote_addr - $remote_user [$time_local] '
'"$request" $status $upstream_addr '
'"$http_referer" "$htpp_user_agent"';
server {
listen 80;
access_log /var/log/nginx/access.log compression;
root /var/www;
index index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}
location ~* \.(?:css|js)$ {
try_files $uri =404;
expires 1y;
access_log off;
add_header Cache-Control "public";
}
location ~ ^.+\..+$ {
try_files $uri =404;
}
}
}