This repository has been archived by the owner on Mar 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #339 from OpenBazaar/TS_docker
Ts docker
- Loading branch information
Showing
15 changed files
with
717 additions
and
13 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ _testmain.go | |
.idea/ | ||
*.iml | ||
.gx/ | ||
dist | ||
|
||
# Development environment files | ||
.ackrc | ||
|
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,14 @@ | ||
FROM ubuntu | ||
MAINTAINER OpenBazaar Developers | ||
|
||
RUN apt-get update && apt-get install -y ca-certificates | ||
|
||
EXPOSE 4001 | ||
EXPOSE 4002 | ||
EXPOSE 8080 | ||
|
||
VOLUME /var/openbazaar | ||
|
||
COPY ./dist/openbazaar-go-linux-amd64 /opt/openbazaard | ||
|
||
CMD ["/opt/openbazaard", "start", "-t", "-d", "/var/openbazaar"] |
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,38 @@ | ||
## | ||
## Building | ||
## | ||
|
||
deploy: | ||
./deploy.sh | ||
|
||
build: | ||
./build.sh | ||
|
||
build_linux: | ||
./build.sh linux/amd64 | ||
|
||
## | ||
## docker | ||
## | ||
DOCKER_PROFILE ?= openbazaar | ||
DOCKER_IMAGE_NAME ?= $(DOCKER_PROFILE)/openbazaard | ||
|
||
build_docker: | ||
docker build -t $(DOCKER_IMAGE_NAME) . | ||
|
||
push_docker: | ||
docker push $(DOCKER_IMAGE_NAME) | ||
|
||
docker: build_linux build_docker push_docker | ||
|
||
## | ||
## Cleanup | ||
## | ||
|
||
clean_build: | ||
rm -f ./dist/* | ||
|
||
clean_docker: | ||
docker rmi -f $(DOCKER_IMAGE_NAME); true | ||
|
||
clean: clean_build clean_docker |
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,10 @@ | ||
#!/bin/bash | ||
|
||
TARGETS=${1:-windows/386,windows/amd64,darwin/amd64,linux/386,linux/amd64,linux/arm} | ||
|
||
export CGO_ENABLED=1 | ||
docker pull karalabe/xgo-latest | ||
go get github.com/karalabe/xgo | ||
mkdir dist | ||
(cd dist/ && xgo --targets=$TARGETS ../) | ||
(chmod +x ./dist/*) |
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
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 @@ | ||
version: '2' | ||
|
||
services: | ||
openbazaard: | ||
build: . | ||
ports: | ||
- 4001 | ||
- 4002 | ||
volumes: | ||
- obdata:/var/openbazaar | ||
|
||
volumes: | ||
obdata: |
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,7 @@ | ||
FROM openbazaar/openbazaard:latest | ||
MAINTAINER OpenBazaar Developers | ||
|
||
COPY ./run.sh /opt/run.sh | ||
COPY ./dist/dummy-linux-amd64 /opt/dummy | ||
|
||
CMD ["/opt/run.sh"] |
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,37 @@ | ||
## | ||
## Building | ||
## | ||
|
||
build: build_linux build_docker_image | ||
build_linux: | ||
docker pull karalabe/xgo-latest | ||
go get github.com/karalabe/xgo | ||
mkdir dist; true | ||
(cd dist && xgo --targets=linux/amd64 ../) | ||
(chmod +x ./dist/*) | ||
|
||
## | ||
## docker | ||
## | ||
DOCKER_PROFILE ?= openbazaar | ||
DOCKER_IMAGE_NAME ?= $(DOCKER_PROFILE)/openbazaard_dummy | ||
|
||
build_docker: | ||
docker build -t $(DOCKER_IMAGE_NAME) . | ||
|
||
push_docker: | ||
docker push $(DOCKER_IMAGE_NAME) | ||
|
||
docker: build_linux build_docker push_docker | ||
|
||
## | ||
## Cleanup | ||
## | ||
|
||
clean_build: | ||
rm -f ./dist/* | ||
|
||
clean_docker: | ||
docker rmi -f $(DOCKER_IMAGE_NAME); true | ||
|
||
clean: clean_build clean_docker |
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,140 @@ | ||
package main | ||
|
||
import ( | ||
"math/rand" | ||
"strconv" | ||
|
||
"github.com/OpenBazaar/openbazaar-go/pb" | ||
"github.com/golang/protobuf/ptypes/timestamp" | ||
"github.com/icrowley/fake" | ||
) | ||
|
||
var conditions = []string{"New", "Used", "Bad", "Most Excellent"} | ||
|
||
var categories = []string{ | ||
"Arts", | ||
"Electronics", | ||
"Entertainment", | ||
"Home", | ||
"Food", | ||
"Personal", | ||
"Services", | ||
"Digital Goods", | ||
"Other", | ||
} | ||
|
||
func newRandomListing() *pb.ListingReqApi { | ||
title := fake.ProductName() | ||
slug := slugify(title) | ||
sku := slug + "-" + fake.Digits() | ||
|
||
tags := make([]string, rand.Intn(9)+1) | ||
tags[0] = fake.Word() | ||
for i := 1; i < len(tags); i++ { | ||
tags[i] = fake.Word() | ||
} | ||
|
||
// Create a random amount of options with random amounts of varients | ||
options := make([]*pb.Listing_Item_Option, rand.Intn(4)+2) | ||
for i := 0; i < len(options); i++ { | ||
options[i] = &pb.Listing_Item_Option{ | ||
Name: fake.ProductName(), | ||
Description: fake.Sentence(), | ||
Variants: make([]*pb.Listing_Item_Option_Variants, rand.Intn(2)+2), | ||
} | ||
|
||
// Ensure description is <= 70 | ||
if len(options[i].Description) > 70 { | ||
options[i].Description = options[i].Description[:70] | ||
} | ||
|
||
for j := 0; j < len(options[i].Variants); j++ { | ||
options[i].Variants[j] = &pb.Listing_Item_Option_Variants{ | ||
Name: title + " " + fake.ProductName(), | ||
Image: &pb.Listing_Item_Image{ | ||
Filename: "example.jpg", | ||
Original: "QmdfiTnhj1oqiCDmhxu1gdgW6ZqtR7D6ZE7j7CqWUHgKJ8", | ||
Tiny: "QmbKPEBbzVwax8rnrdxLepfmNkdTqnw2RSfJE19iax3fLK", | ||
Small: "QmQ77aAsYjs1rxcp7xZ5qUki1RGDGjQ99cok3ynUMF8Sc5", | ||
Medium: "QmVoh493xbSaKYV9yLtEapaGQ7J31gdCiDQHGSd86PNo8B", | ||
Large: "QmUWuTZhjUuY8VYWVZrcodsrsbQvckSZwTRxmJ3Avhnw1y", | ||
}, | ||
PriceModifier: int64(rand.Intn(50)), | ||
} | ||
|
||
// Ensure name is <= 40 chars | ||
if len(options[i].Variants[j].Name) > 40 { | ||
options[i].Variants[j].Name = options[i].Variants[j].Name[:40] | ||
} | ||
} | ||
} | ||
|
||
countries := make([]pb.CountryCode, rand.Intn(254)+1) | ||
for i := 0; i < len(countries); i++ { | ||
countries[i] = pb.CountryCode(rand.Intn(255)) | ||
} | ||
|
||
return &pb.ListingReqApi{ | ||
Listing: &pb.Listing{ | ||
Slug: slug, | ||
Metadata: &pb.Listing_Metadata{ | ||
Version: 1, | ||
AcceptedCurrency: "btc", | ||
PricingCurrency: "btc", | ||
Expiry: ×tamp.Timestamp{Seconds: 2147483647}, | ||
Format: pb.Listing_Metadata_FIXED_PRICE, | ||
ContractType: pb.Listing_Metadata_ContractType(uint32(rand.Intn(3))), | ||
}, | ||
Item: &pb.Listing_Item{ | ||
Sku: sku, | ||
Title: title, | ||
Tags: tags, | ||
Options: options, | ||
Nsfw: isNSFW(), | ||
Description: fake.Paragraphs(), | ||
Price: uint64(rand.Intn(9999)), | ||
ProcessingTime: strconv.Itoa(rand.Intn(14)+1) + " days", | ||
Categories: []string{categories[rand.Intn(len(categories))]}, | ||
Grams: float32(rand.Intn(5000)), | ||
Condition: conditions[rand.Intn(len(conditions))], | ||
Images: []*pb.Listing_Item_Image{ | ||
{ | ||
Filename: "example.jpg", | ||
Original: "QmdfiTnhj1oqiCDmhxu1gdgW6ZqtR7D6ZE7j7CqWUHgKJ8", | ||
Tiny: "QmbKPEBbzVwax8rnrdxLepfmNkdTqnw2RSfJE19iax3fLK", | ||
Small: "QmQ77aAsYjs1rxcp7xZ5qUki1RGDGjQ99cok3ynUMF8Sc5", | ||
Medium: "QmVoh493xbSaKYV9yLtEapaGQ7J31gdCiDQHGSd86PNo8B", | ||
Large: "QmUWuTZhjUuY8VYWVZrcodsrsbQvckSZwTRxmJ3Avhnw1y", | ||
}, | ||
}, | ||
}, | ||
ShippingOptions: []*pb.Listing_ShippingOption{ | ||
{ | ||
Name: "usps", | ||
Type: pb.Listing_ShippingOption_FIXED_PRICE, | ||
Regions: countries, | ||
Services: []*pb.Listing_ShippingOption_Service{ | ||
{ | ||
Name: "standard", | ||
Price: uint64(rand.Intn(999)), | ||
EstimatedDelivery: fake.Digits() + " days", | ||
}, | ||
}, | ||
ShippingRules: &pb.Listing_ShippingOption_ShippingRules{ | ||
RuleType: pb.Listing_ShippingOption_ShippingRules_FLAT_FEE_QUANTITY_RANGE, | ||
Rules: []*pb.Listing_ShippingOption_ShippingRules_Rule{ | ||
{ | ||
MinRange: 0, | ||
MaxRange: 99999999, | ||
Price: uint64(rand.Intn(999)), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
||
TermsAndConditions: fake.Sentences(), | ||
RefundPolicy: fake.Sentence(), | ||
}, | ||
} | ||
} |
Oops, something went wrong.