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

Commit

Permalink
Merge pull request #6 from bemble/python_server
Browse files Browse the repository at this point in the history
Move server from go to Python
  • Loading branch information
bemble authored May 7, 2024
2 parents 4cacff6 + 1830579 commit 1d4d3a7
Show file tree
Hide file tree
Showing 143 changed files with 4,630 additions and 4,386 deletions.
13 changes: 13 additions & 0 deletions .code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"folders": [
{
"path": "front"
},
{
"path": "server"
},
{
"path": "."
}
]
}
22 changes: 17 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,35 @@
"image": "mcr.microsoft.com/devcontainers/base:debian",
"features": {
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/devcontainers/features/go:1": {}
"ghcr.io/devcontainers/features/go:1": {},
"ghcr.io/devcontainers/features/python:1": {
"version": "3.12"
}
},
"postCreateCommand": "npm install -g nodemon && cd front && npm i && cd ..",
"forwardPorts": [8781, 3000],
"postCreateCommand": "npm install -g nodemon && cd front && npm i && cd ../server && python -m venv .venv",
"forwardPorts": [8765, 3000],
"customizations": {
"vscode": {
"settings": {
"python.testing.pytestArgs": ["--no-cov"],
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[go]": {
"editor.defaultFormatter": "golang.go"
},
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff"
},
"files.trimTrailingWhitespace": true
},
"extensions": ["esbenp.prettier-vscode", "golang.go"]
"extensions": [
"esbenp.prettier-vscode",
"golang.go",
"charliermarsh.ruff",
"ms-python.python"
]
}
}
}
}
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ test
.env
.DS_Store
data
server/build
server/main
server_go

front/.eslintcache
front/node_modules
/public/
front/build

!front/.env
!front/.env


server/.venv
__pycache__
41 changes: 0 additions & 41 deletions .vscode/tasks.json

This file was deleted.

33 changes: 8 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,43 +1,26 @@
# Server build
FROM golang:1.20-alpine as server-builder

RUN apk add --no-cache \
alpine-sdk \
ca-certificates \
tzdata

# Force the go compiler to use modules
ENV GO111MODULE=on

ADD . /app
WORKDIR /app/server
RUN CGO_ENABLED=0 GOOS=linux go build -a -o holerr .

# Front build
FROM node:14-alpine as front-builder
RUN apk add --no-cache --virtual python3 py3-pip make g++
RUN apk add tzdata
FROM node:20-alpine as front-builder
RUN apk add --no-cache python3 py3-pip make g++

ADD . /app
WORKDIR /app/front
RUN npm ci install
RUN CI=false GENERATE_SOURCEMAP=false npm run build:docker

# Final image
FROM scratch
FROM python:3.12-alpine

ARG APP_VERSION
ENV IS_IN_DOCKER=1
ENV APP_VERSION=${APP_VERSION}

# copy front files
COPY --from=front-builder /app/public /app/public

# copy server files
COPY --from=server-builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=server-builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=server-builder /app/server/holerr /app/server/holerr
COPY ./server /app/server

ENTRYPOINT ["/app/server/holerr"]
WORKDIR /app/server
RUN pip install -r requirements.txt
CMD ["python", "-m", "holerr"]

EXPOSE 8781
EXPOSE 8765
Loading

0 comments on commit 1d4d3a7

Please sign in to comment.