diff --git a/Dockerfile b/Dockerfile index e5914e56..5b116dfa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,18 @@ FROM golang:alpine AS build -RUN apk add --no-cache curl git +RUN apk add --no-cache curl git gcc linux-headers musl-dev RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh +ARG GO_SWAGGER_VERSION=0.18.0 +ARG SWAGGER_UI_VERSION=3.20.9 + +RUN curl -sfL -o /usr/local/bin/swagger https://github.com/go-swagger/go-swagger/releases/download/v$GO_SWAGGER_VERSION/swagger_linux_amd64 \ + && chmod +x /usr/local/bin/swagger \ + && curl -sfL https://github.com/swagger-api/swagger-ui/archive/v$SWAGGER_UI_VERSION.tar.gz | tar xz -C /tmp/ \ + && mv /tmp/swagger-ui-$SWAGGER_UI_VERSION /tmp/swagger \ + && sed -i 's#"https://petstore\.swagger\.io/v2/swagger\.json"#"./swagger.json"#g' /tmp/swagger/dist/index.html + WORKDIR $GOPATH/src/github.com/vibrato/TechTestApp COPY Gopkg.toml Gopkg.lock $GOPATH/src/github.com/vibrato/TechTestApp/ @@ -13,6 +22,7 @@ RUN dep ensure -vendor-only -v COPY . . RUN go build -o /TechTestApp +RUN swagger generate spec -o /swagger.json FROM alpine:latest @@ -21,6 +31,8 @@ WORKDIR /TechTestApp COPY assets ./assets COPY conf.toml ./conf.toml +COPY --from=build /tmp/swagger/dist ./assets/swagger +COPY --from=build /swagger.json ./assets/swagger/swagger.json COPY --from=build /TechTestApp TechTestApp ENTRYPOINT [ "./TechTestApp", "serve" ] diff --git a/assets/js/app.jsx b/assets/js/app.jsx index 4d978742..f93c6974 100644 --- a/assets/js/app.jsx +++ b/assets/js/app.jsx @@ -7,10 +7,10 @@ class TaskContainer extends React.Component { this.state ={ tasks: [{ - Id: 0, - Title: "Loading...", - Completed: false, - Priority: 0 + id: 0, + title: "Loading...", + completed: false, + priority: 0 }] }; } @@ -30,22 +30,22 @@ class TaskContainer extends React.Component { deleteTask(task) { console.log(task) - + var filteredTasks = this.state.tasks.filter(function (item) { - return (item.ID !== task.ID); + return (item.id !== task.id); }); console.log(filteredTasks) - - this.setState({tasks: filteredTasks}); - fetch("/api/task/" + task.ID + "/", { + this.setState({tasks: filteredTasks}); + + fetch("/api/task/" + task.id + "/", { method: "DELETE", }) } - + render() { return ( @@ -70,8 +70,8 @@ class TaskList extends React.Component { render() { return(