Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
feat(webapp oci):initial version of webapp image
Browse files Browse the repository at this point in the history
  • Loading branch information
fczuardi committed Dec 6, 2023
1 parent ab5906e commit ee804b6
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ config.yaml
results
venv
mgc
./nginx.conf
14 changes: 13 additions & 1 deletion example.config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
current_remote: "example-mgc"
# credentials and endpoints for multiple object storage providers
remotes:
aws-east-1:
s3:
Expand Down Expand Up @@ -32,3 +32,15 @@ remotes:
region: us-east-1
access_key: "test:tester"
secret_key: "testing"

# TODO: mgc tool supports only one remote / profile, this config will be deprecated in the future
current_remote: "example-mgc"

# config for a webserver to expose results in a website, see webapp.Dockerfile
webapp:
nginx:
listen: 5000
server_name: localhost
locations:
"/":
root: "/app/results"
7 changes: 7 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ k6_iterations := "1"

# OCI
main_image := "ghcr.io/marmotitude/object-storage-tests:main"
webapp_image := "ghcr.io/marmotitude/object-storage-tests:webapp"
devshell_image := "docker.io/fczuardi/object-storage-tests:devshell"
distrobox_name := "devshell-obj"

Expand Down Expand Up @@ -124,6 +125,12 @@ build builder=oci_manager:
build-dev builder=oci_manager:
{{builder}} build --rm -t {{devshell_image}} -f ./devshell.Dockerfile .

# Build webapp image.
build-webapp builder=oci_manager:
# write ./nginx.conf to be copied by Dockerfile
gotpl -f config.yaml src/templates/nginx.conf --output .
{{builder}} build --rm -t {{webapp_image}} -f ./webapp.Dockerfile .


# Private recipes
#----------------
Expand Down
23 changes: 23 additions & 0 deletions src/templates/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Set number of worker processes automatically based on number of CPU cores.
worker_processes auto;

events {
# The maximum number of simultaneous connections that can be opened by
# a worker process.
worker_connections 1024;
}

http {
server {
listen {{ .webapp.nginx.listen }};
server_name {{ .webapp.nginx.server_name }};

{{- range $location_name, $location := .webapp.nginx.locations}}
location {{ $location_name }} {
root {{ $location.root }};
index index.html;
autoindex on;
}
{{- end}}
}
}
36 changes: 36 additions & 0 deletions webapp.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Use main image as base
FROM ghcr.io/marmotitude/object-storage-tests:main

# Install Nginx
RUN apk update && \
apk add nginx

# Keep a backup of alpine's default nginx config
RUN mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.orig

# Copy our custom Nginx configuration
COPY nginx.conf /etc/nginx/nginx.conf

# Set the working directory to /app
WORKDIR /app

# Create the directory for the results
RUN mkdir -p results

# Set ownership and permissions for Nginx to read from /app/results
RUN chown -R root:root results && \
chmod -R 755 results

# Write dummy file to results directory with a smile and timestamp
RUN printf ":-)\n\nBuilded on $(date) by:$(hostname)" > results/smile.txt

# Copy the shell script that runs desired tests outputing to results folder
# this script will be executed by an external scheduler periodically
# TBD

# Expose port 5000
EXPOSE 5000

# Override the main image's entry point and set the default command
ENTRYPOINT ["nginx", "-g", "daemon off;"]
CMD []

0 comments on commit ee804b6

Please sign in to comment.