-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created Dockerfiles and K8s yml files to deploy backend and frontend (#…
…81) * Created Dockerfiles and K8s yml files to deploy backend and frontend Signed-off-by: danbugs <[email protected]> * fix && fmt Signed-off-by: danbugs <[email protected]> --------- Signed-off-by: danbugs <[email protected]>
- Loading branch information
Showing
11 changed files
with
225 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM rust:latest | ||
|
||
# Set the working directory in the container | ||
WORKDIR /usr/src/smithereens | ||
|
||
# Copy the entire workspace | ||
COPY . . | ||
|
||
# Build the project | ||
RUN cargo build --release --package smithe_backend | ||
|
||
# Specify the command to run the binary | ||
CMD ["./target/release/smithe_backend"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
FROM rust:latest AS builder | ||
|
||
# Define build-time variables | ||
ARG SERVER_ADDRESS | ||
ARG RECAPTCHA_SITE_KEY | ||
ARG SERVER_ADDRESS_2 | ||
|
||
WORKDIR /usr/src/smithereens | ||
COPY . . | ||
|
||
# Set environment variables for build | ||
ENV SERVER_ADDRESS=${SERVER_ADDRESS} | ||
ENV RECAPTCHA_SITE_KEY=${RECAPTCHA_SITE_KEY} | ||
ENV SERVER_ADDRESS_2=${SERVER_ADDRESS_2} | ||
|
||
# Add wasm32-unknown-unix to the toolchain | ||
RUN rustup target add wasm32-unknown-unknown | ||
|
||
RUN cargo install trunk | ||
RUN trunk build ./frontend/index.html --release | ||
|
||
FROM nginx:alpine | ||
COPY --from=builder /usr/src/smithereens/frontend/dist /usr/share/nginx/html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: backend-deployment | ||
spec: | ||
replicas: 3 | ||
selector: | ||
matchLabels: | ||
app: backend | ||
template: | ||
metadata: | ||
labels: | ||
app: backend | ||
spec: | ||
containers: | ||
- name: backend | ||
image: danstaken/smithe-backend:latest | ||
imagePullPolicy: Always | ||
ports: | ||
- containerPort: 8000 | ||
env: | ||
- name: PIDGTM_DATABASE_URL | ||
valueFrom: | ||
secretKeyRef: | ||
name: backend-secrets | ||
key: PIDGTM_DATABASE_URL | ||
- name: STARTGG_TOKEN | ||
valueFrom: | ||
secretKeyRef: | ||
name: backend-secrets | ||
key: STARTGG_TOKEN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: backend-service | ||
spec: | ||
type: ClusterIP | ||
selector: | ||
app: backend | ||
ports: | ||
- protocol: TCP | ||
port: 8000 | ||
targetPort: 8000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apiVersion: cert-manager.io/v1 | ||
kind: ClusterIssuer | ||
metadata: | ||
name: letsencrypt-prod | ||
spec: | ||
acme: | ||
# The ACME server URL | ||
server: https://acme-v02.api.letsencrypt.org/directory | ||
# Email address used for ACME registration | ||
email: [email protected] | ||
# Name of a secret used to store the ACME account private key | ||
privateKeySecretRef: | ||
name: letsencrypt-prod | ||
# ACME DNS-01 provider configurations | ||
solvers: | ||
- http01: | ||
ingress: | ||
class: nginx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: frontend-deployment | ||
spec: | ||
replicas: 3 | ||
selector: | ||
matchLabels: | ||
app: frontend | ||
template: | ||
metadata: | ||
labels: | ||
app: frontend | ||
spec: | ||
containers: | ||
- name: frontend | ||
image: danstaken/smithe-frontend:latest | ||
imagePullPolicy: Always | ||
ports: | ||
- containerPort: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: frontend-ingress | ||
annotations: | ||
nginx.ingress.kubernetes.io/rewrite-target: / | ||
cert-manager.io/cluster-issuer: "letsencrypt-prod" | ||
nginx.ingress.kubernetes.io/force-ssl-redirect: "true" | ||
spec: | ||
tls: | ||
- hosts: | ||
- smithe.net | ||
secretName: smithe-net-tls | ||
rules: | ||
- host: smithe.net | ||
http: | ||
paths: | ||
- path: / | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: frontend-service | ||
port: | ||
number: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: frontend-service | ||
spec: | ||
type: LoadBalancer | ||
selector: | ||
app: frontend | ||
ports: | ||
- protocol: TCP | ||
port: 80 | ||
targetPort: 80 |