🚧 working on deployment
This commit is contained in:
parent
f460b514a5
commit
97027a31b9
3 changed files with 80 additions and 0 deletions
backend
27
backend/Dockerfile
Normal file
27
backend/Dockerfile
Normal file
|
@ -0,0 +1,27 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM golang:1.19
|
||||
|
||||
# Set destination for COPY
|
||||
WORKDIR /app
|
||||
|
||||
# Download Go modules
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
# Copy the source code. Note the slash at the end, as explained in
|
||||
# https://docs.docker.com/engine/reference/builder/#copy
|
||||
COPY *.go ./
|
||||
|
||||
# Build
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -o /docker-gs-ping
|
||||
|
||||
# Optional:
|
||||
# To bind to a TCP port, runtime parameters must be supplied to the docker command.
|
||||
# But we can document in the Dockerfile what ports
|
||||
# the application is going to listen on by default.
|
||||
# https://docs.docker.com/engine/reference/builder/#expose
|
||||
EXPOSE 8080
|
||||
|
||||
# Run
|
||||
CMD ["/docker-gs-ping"]
|
|
@ -11,3 +11,10 @@ services:
|
|||
- POSTGRES_PASSWORD=helse123
|
||||
- POSTGRES_USER=admin
|
||||
- POSTGRES_DB=helseveileder
|
||||
ginapi:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: helseveileder
|
||||
depends_on:
|
||||
- postgres
|
||||
|
|
46
backend/nginx/conf/default.conf
Normal file
46
backend/nginx/conf/default.conf
Normal file
|
@ -0,0 +1,46 @@
|
|||
server {
|
||||
listen 443 ssl;
|
||||
server_name status-api.cloudprovider.info;
|
||||
|
||||
# ssl_certificate /etc/nginx/certs/your_domain.crt;
|
||||
# ssl_certificate_key /etc/nginx/certs/your_domain.key;
|
||||
ssl_certificate /etc/nginx/certs/fullchain.pem;
|
||||
ssl_certificate_key /etc/nginx/certs/privkey.pem;
|
||||
|
||||
|
||||
location / {
|
||||
proxy_pass http://ginapi:8000;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
if ($request_method = 'OPTIONS') {
|
||||
add_header 'Access-Control-Allow-Origin' '*';
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
|
||||
#
|
||||
# Custom headers and headers various browsers *should* be OK with but aren't
|
||||
#
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
|
||||
#
|
||||
# Tell client that this pre-flight info is valid for 20 days
|
||||
#
|
||||
add_header 'Access-Control-Max-Age' 1728000;
|
||||
add_header 'Content-Type' 'text/plain; charset=utf-8';
|
||||
add_header 'Content-Length' 0;
|
||||
return 204;
|
||||
}
|
||||
if ($request_method = 'POST') {
|
||||
add_header 'Access-Control-Allow-Origin' '*' always;
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
|
||||
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
|
||||
}
|
||||
if ($request_method = 'GET') {
|
||||
add_header 'Access-Control-Allow-Origin' '*' always;
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
|
||||
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
|
||||
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
|
||||
}
|
||||
}
|
||||
}
|
Reference in a new issue